删除数据 <?php $con = mysql_connect("localhost","root","") or die("error"); $mysql = mysql_select_db("monkey",$con); $sql = "delete from rote where id <=4"; //$sql = "delete from rote where id='".$id."'"; mysql_query($sql,$con); $row = mysql_affected_rows(); //返回影响行数 echo $row." "; if($row > 0){ echo "删除成功"; }else{ echo "删除失败"; } mysql_close(); ?> 插入数据 <?php $con = mysql_connect("localhost","root",""); $mysql = mysql_select_db('monkey',$con); $name = 'a'; $phone = 'b'; $parts = 'c'; $content = 'd'; $sPic = 'xy/image/1407907747.jpg'; $bPic = 'xy/image/1407907747.jpg'; $cTime = '1407907747'; $sql = "insert into rote (name,phone,parts,content,sPic,bPic,cTime) values('$name','$phone','$parts','$content','$sPic','$bPic','$cTime')"; if(mysql_query($sql,$con)){ echo "添加一条数据"; }else{ die(mysql_error()); } mysql_close(); ?>