您的位置:首页 > 数据库 > MySQL

MySQL循环遍历执行查询SQL语句结果的方法

2015-08-19 20:20 891 查看
<?php
$conn=mysql_connect("localhost","root","123456") or die(mysql_error());
$set=mysql_select_db("vt",$conn)or die(mysql_error());
mysql_query("SET NAMES `GBK`");
$sql="SELECT * FROM `user`";
$query=mysql_query($sql);
?>
<table>
<tr>
<td>id</td>
<td>username</td>
</tr>
<?php
while($row=mysql_fetch_array($query))
{
?>
<tr>
<td><?php echo $row["id"]?></td>
<td><?php echo $row["username"]?></td>
</tr>
<?php
}
?>
</table>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: