$conn = mysqli_connect(...);
$stmt = mysqli_query(..., "SELECT * FROM mydb.mydata ORDER BY mydata.serialno DESC Limit 20 ");$row = mysqli_num_rows($stmt);
$col = mysqli_num_fields($stmt);for ($i = 0;$i < $row ;$i++)
{
@mysqli_data_seek($stmt, $i);
$rowdata = @mysqli_fetch_array($stmt);
print_r($rowdata);
}lz甚至没告诉用的哪个数据库
while($arr=mysql_fetch_array($result))
{
echo $arr[0];
echo $arr[1];
......
}
<meta charset="utf-8"/>
<?php
/**
连接数据裤
1.主机名称
2.用户名
3.密码
**/
$link = mysql_connect("localhost","root","123456");
//选择要使用的数据库
mysql_select_db("dbphp");
//对数据库查询的SQL语句,想查什么表只需要把后面的student表名替换掉就行了
$strsql= "select * from student";
//执行查询
$result=mysql_query($strsql,$link);
//提取数据库信息,并以表格的形式打印
echo " <table border=9>\n";
echo " <tr>\n";
//获取表头信息用函数mysql_fetch_field()
while ($field=mysql_fetch_field($result)){
echo " <td>".$field->name." </td>\n";}
echo " </tr>\n";
//获取第一行信息用mysql_fetch_row()
while ($row=mysql_fetch_row($result)){
echo " <tr>\n";
//遍历所以需要显示出来的信息
for($r=0;$r <count($row);$r++){
echo " <td>".$row[$r]." </td>\n";
}
echo " </tr>\n";
}
echo " </table>\n";
echo " </p> </center>";
//释放资源
mysql_free_result($result);
//关闭连接
mysql_close($link);
?>