dongyoudi1342 2011-07-17 04:17
浏览 8
已采纳

在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++;
}

I get blank result.

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.

  • 写回答

3条回答 默认 最新

  • duan0818 2011-07-17 04:20
    关注

    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++;
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?