php mysqli

<?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=Ƈ'>
<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> ";
}
}
echo "</table>";
}
?>
</body>
</html>

    A+
发布日期:2009年04月11日  所属分类:未分类

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: