Php 虽然循环不起作用

Php 虽然循环不起作用,php,loops,while-loop,Php,Loops,While Loop,嗨,伙计们,我正在做while循环 while循环将遍历所有订单。 它可以工作,但在循环查看订单状态时却无法工作。 例如,订单4状态为挂起,但订单5状态未显示任何内容。 我怀疑我把括号放错了 这是我的密码 <form action="results-action" method="post" enctype="multipart/form-data"> <fieldset> <table width="600" border="1"> <tr>&

嗨,伙计们,我正在做while循环

while循环将遍历所有订单。 它可以工作,但在循环查看订单状态时却无法工作。 例如,订单4状态为挂起,但订单5状态未显示任何内容。 我怀疑我把括号放错了

这是我的密码

<form action="results-action" method="post" enctype="multipart/form-data">
<fieldset>

<table width="600" border="1">
<tr><td><h2>Pending Order</h2></td></tr>
<tr>

<th scope="col">Order ID</th>
<th scope="col">Name</th>
<th scope="col">Address</th>
<th scope="col">Product Name</th>
<th scope="col">Produt Quantity</th>
<th scope="col">Price</th>
<th scope="col">Order status</th>
</tr>

<?php
while ($row = mysqli_fetch_array($result)) {
?>

<tr>
<td><input type="text" value='<?=$row['virtuemart_order_id']?>' name="orderid" id="virtuemart_order_id"></td>
<td><?=$row['first_name']?></td>
<td><?=$row['address_1']?></td>
<td><?=$row['order_item_name']?></td>
<td><?=$row['product_quantity']?></td>
<td><?=$row['product_final_price'] ?></td>
<td><select name="change">
    <?php 
    while ($row2 = mysqli_fetch_array($result2)) {
    ?>
    <option value="<?=$row2['order_status_code'] ?>"><?=$row2['order_status_name'] ?></option>
    <?php
    } //end inner while
    ?>
</td>
</tr>

<?php
} //end outer while
?>

</table>
</fieldset>

<fieldset>
<table>
<tr>
<td><input type="submit" value="Update status" name="update status"> </td>
</tr>
</table>
</fieldset>
</form>

待决订单
订单号
名称
地址
品名
产品数量
价格
订单状态

如果您想在
期间每次在内部
中获得相同的行,则必须重置mysqli结果集的内部指针。为此,您可以使用

你会得到这样的结果:

while ($row = mysqli_fetch_array($result)) {
    // snip ...
    while ($row2 = mysqli_fetch_array($result2)) {
        // snip
    }
    mysqli_data_seek($result2, 0);
    // snip
}

还请确保
具有唯一的名称,否则将错误捕获您的所有状态

<select name="change_<?=$row['row_id']?>">

什么是
$result
$result2
?如果您不以某种方式重置
$result2
,我看不出内部
如何能运行多次。顺便说一句,您没有结束
。这不会解决您当前的问题,但请查看和。还有一个adivce。使用
join
,因为在我看来,这可以通过一个查询完成。