$dbhost ="127.0.0.1"
$dbuser = "root"
$dbpwd = "root"
$dbname = "test"
$charName = "'UTF8'" //设置查询字符集gbk,gbk2312,utf-8
$mysqli = new mysqli($dbhost,$dbuser,$dbpwd,$dbname)
if (mysqli_connect_errno()){ //注意mysqli_connect_error()新特性
die('Unable to connect!'). mysqli_connect_error()
}
$sql = "SET NAMES ".$charName
$mysqli->query($sql)
$result=$mysqli->query("select * from tttt order by id //根据前面的计算出开始的记录和记录数
while ($row=mysqli_fetch_array($result,MYSQLI_ASSOC)){
$htmlstr.=$row['id']." </br>"
}
echo $htmlstr
$sql="select * from user" $result=$link->query($sql) $row=$result->fetch_all(MYSQLI_BOTH)//参数MYSQL_ASSOC、MYSQLI_NUM、MYSQLI_BOTH规定产生数组类型$n=0 while($n<mysqli_num_rows($result)){ echo "ID:".$row[$n]["id"]."用户名:".$row[$n]["name"]."密码:".$row[$n]["password"]."<br />" $n++
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)