标签:
查询数据库里面有多少条数据$m=new mysqli(‘localhost‘,‘root‘,‘‘,‘db‘);
$m->set_charset(‘utf8‘);
$stmt=$m->prepare(‘select count(*) from stu‘);
$stmt->execute();
$stmt->bind_result($c);
$stmt->fetch();
echo $c;
$stmt->free_result();
$stmt->close();
$m->close();
$m=new mysqli(‘localhost‘,‘root‘,‘‘,‘db‘);
$m->set_charset(‘utf8‘);
$stmt=$m->prepare(‘select * from stu where 1=1‘);
$stmt->execute();
$stmt->bind_result($id,$name,$sgender,$sscore);
while($stmt->fetch()){
echo "$id,$name,$sgender,$sscore".‘<br>‘;
}
$stmt->free_result();
$stmt->close();
$m->close();
$m=new mysqli(‘localhost‘,‘root‘,‘‘,‘db‘);
$m->set_charset(‘utf8‘);
$stmt=$m->prepare(‘select * from stu where 1=1‘);
$stmt->execute();
$result=$stmt->get_result();
$rows=$result->fetch_all(2);
foreach($rows as $v){
print_r($v).‘<br>‘;
}
$stmt->free_result();
$stmt->close();
$m->close();
$m=new mysqli(‘localhost‘,‘root‘,‘‘,‘db‘);
$m->set_charset(‘utf8‘);
$stmt=$m->prepare(‘select * from stu where sid=?‘);
$n=10;
$stmt->bind_param(‘i‘,$n);
$stmt->execute();
$stmt->bind_result($id,$name,$sgender,$sscore);
$stmt->fetch();
echo $id,$name,$sgender,$sscore;
$stmt->free_result();
$stmt->close();
$m->close();
标签:
原文地址:http://www.cnblogs.com/lsr111/p/4544801.html