准备好的语句:我正在使用两个 while 循环,但我的内部 while 循环不起作用。当我使用内部while循环时,它只显示一条记录,但是当我删除内部while循环时,我可以看到所有记录..我该如何解决?
这是我的代码
<table width="100%" style="background-color:#F2F2F2;border:1px solid #F2F2F2;border-radius:15px;">
<form name="form1" id="form1" method="post" action="">
<tr>
<td align="">
<table width="100%" style="background-color:#F2F2F2;border:1px solid #F2F2F2;border-radius:15px;">
<tr class="table-heading">
<td > Qty.</td>
<td > Writer</td>
<td > Status</td>
<td > </td>
</tr><?php
if($stmt->prepare("select id,qty,action_flag,status,writer from tbl_order where status=? and action_flag=? and order_id=?"))
{
$action='confirm';
$status='orderprocessing';
$ordid=$_GET["ordid"];
$stmt->bind_param('sss',$status,$action,$ordid);
$stmt->execute();
$stmt->store_result();
$stmt->bind_result($id,$qty,$action_flag,$status,$writer);
}
while($stmt->fetch()) // outer while loop
{
?>
<tr align="left" style="line-height:30px;font-size:12px;">
<td > <?php echo $qty; ?></td>
<td align="center" width="160" >
<select name="selwrt" id="selwrt" class="reginput" style="text-transform:capitalize;width:150px;height:25px;" >
<option value="">Select Writer</option>
<?php
if($stmt->prepare("select id,writer_name from tbl_writer order by writer_name"))
{
$stmt->execute();
$stmt->store_result();
$stmt->bind_result($wid,$writer_name);
}
while($stmt->fetch()) // inner while loop
{
?>
<option value="<?php echo $wid; ?>"<?php if($writer==$wid) echo 'selected="selected"'; ?>><?php echo $writer_name; ?></option><?php } ?>
</select>
</td>
<td align="center" width="160" ><select name="selst" id="selst" class="reginput" style="text-transform:capitalize;width:150px;height:25px;">
<option value="">Select Status</option>
<option value="inprogress"<?php if($status=='inprogress') echo 'selected="selected"'; ?>>In Progress</option>
<option value="jobdone"<?php if($status=='jobdone') echo 'selected="selected"'; ?>>Job Done</option>
</select>
</td>
<td style="vertical-align:top;" ><input type="submit" name="btnsave" id="btnsave" value="SAVE" class="btnstyle" style="padding:3px;"/>
<input type="hidden" name="pid" id="pid" value="<?php echo $id; ?>" ></td>
</tr><?php } ?>
<tr><td> </td></tr>
</table>