PHP中的循环无法正常工作 [英] Loop in PHP not working

查看:56
本文介绍了PHP中的循环无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

$qPhysician = mysql_query("SELECT * FROM physicians");
$num = mysql_num_rows($qPhysician);
$i=0;
while($i < $num)
{
    "<tr>";
    "<td>" . mysql_result($qPhysician,$i,"lastName") . "</td>";
    "<td>" . mysql_result($qPhysician,$i,"firstName") . "</td>";
    "</tr>";
    $i++;
}

我得到空白结果.

如果回显 $ num ,则会得到"19",这是数据库中的行数.如果我回显 $ rowPhysician ['lastName'] 只是为了测试是否获得记录,则至少会获得1条姓氏记录.我不知道"while"是否有问题.请帮帮我.

If I echo $num, I get "19" which is the number of rows in my DB. If I echo $rowPhysician['lastName'] just to test out if I get records, I get at least 1 record of last name. I don't know if there is something wrong with "while". Please help me out.

推荐答案

您是否缺少回显信息以打印出字符串?

Are you missing the echo to print out the strings?

while($i < $num) {
    echo "tr";
    echo "td" . mysql_result($qPhysician,$i,"lastName") . "/td";
    echo "td" . mysql_result($qPhysician,$i,"firstName") . "/td";
    echo "/tr";
    $i++;
}

这篇关于PHP中的循环无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆