Chr*_*rus 2 html php mysql sql while-loop
我有一个数据库(SQL),其中包含"Staff"表,其中包含两个记录.我需要使用PHP在网页上显示这些记录的内容.
<html>
<head>
<title>CES Staff details</title>
</head>
<body>
**code emitted**
<?php
$row = mysql_fetch_array($result) ;
$looping = 1;
$i = $row.length;
while ($looping <= $i)
{
echo $row["Name"].", Room ".$row["Room"].", Tel ".$row["Telephone"] ;
$looping++;
}
?>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
如何正确更改while循环,以便在页面上显示两个记录.
谢谢!
Mic*_*ski 15
mysql_fetch_array()仅从数据库中检索单个行.您需要在while循环内调用它来检索所有行.该$looping增量是不必要在这里,因为mysql_fetch_array()返回false时,没有更多行可供选择.
while ($row = mysql_fetch_array($result))
{
echo $row["Name"].", Room ".$row["Room"].", Tel ".$row["Telephone"] ;
}
Run Code Online (Sandbox Code Playgroud)