【发布时间】:2015-12-19 08:58:13
【问题描述】:
是否可以使用两个 while 语句比较两个表中的值。我正在使用以下不起作用的方式。请指出我的错误或建议我更简单的解决方案。
$sql = "select * from display where gp_no = '$gp_no' ";
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) > 0)
{
$s = " select date,member_no from bid where gp_no = '$gp_no ' ";
$r = mysqli_query($conn, $s);
if (mysqli_num_rows($r) > 0)
{
while($row = mysqli_fetch_assoc($result))
{
while($row1 = mysqli_fetch_assoc($r))
{
if($row["member_no"] = $row1[ " member_no"])
{
//some code to display something
} // inner if
} // inner while
} // outer while
} // outer if
} // outermost if
【问题讨论】:
-
为什么不试试子查询或者加入查询呢??
-
因为我已经使用 join 创建了一个视图。那是我的一张桌子(视图)。现在,不可能将该视图与另一个表连接起来,因为这样会给出错误的结果。
标签: php mysql if-statement while-loop row