我试图让用户输入一个帐号,并在商家名称下面显示。
以下是我正在使用的代码,该代码从表单中调用:
<?php
$q = intval($_GET['q']);
$con = mysql_connect("localhost","cl49-xxx","xxx");
if (!$con)
{
die('Could not connect: ' . mysqli_error($con));
}
mysqli_select_db($con,"cl49-xx");
$sql="SELECT * FROM member WHERE personID = '".$q."'";
$result = mysqli_query($con,$sql);
echo "Business Name:<table>";
while($row = mysqli_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['businesstype'] . "</td>";
echo "</tr>";
}
echo "</table>";
mysqli_close($con);
?>
当我运行此代码时,它只显示business name:
。
答案 0 :(得分:0)
我认为你在循环附近有问题。而不是“while($ row = mysqli_fetch_array($ result))”。你为什么不用这个:
$row = mysqli_fetch_array($result);
$i= 0;
while( $i<count($row))
{
echo "<tr>";
echo "<td>" . $row['businesstype'] . "</td>";
echo "</tr>";
$i++;
}
echo "</table>";