php列出表所有字段及值

发布时间:2013-12-19 23:48:46 阅读:1160次
 <?php
echo "<html>
<head><title>Test MySQL</title></head>
<body>";
$host="localhost";
$user="root";
$password="";
$cxn = mysqli_connect($host,$user,$password);
$db=mysqli_select_db($cxn,"test");
$sql="select * from userinfo";
$result = mysqli_query($cxn,$sql);
if($result == false)
{
echo "<h4>Error: ".mysqli_error($cxn)."</h4>";
}
else
{
/* Table that displays the results */
echo "<table border='1'>
<tr><th>Variable_name</th>
<th>Value</th></tr>";
for($i = 0; $i < mysqli_num_rows($result); $i++)
{
echo "<tr>";
$row_array = mysqli_fetch_row($result);
for($j = 0;$j < mysqli_num_fields($result);$j++)
{
echo "<td>".$row_array[$j]."</td>\n";
}
}
echo "</table>";
}
?>
</body>
</html>
 

如有问题,可以QQ搜索群1028468525加入群聊,欢迎一起研究技术

支付宝 微信

有疑问联系站长,请联系QQ:QQ咨询

转载请注明:php列出表所有字段及值 出自老鄢博客 | 欢迎分享