我需要获取所选选择的值 就像更改的行的 orderno
表格看起来像这样
如果我将订单号 1002 更改为已售出
$query = mysql_query("select * from orders");
while($row = mysql_fetch_assoc($query))
{
echo '<tr>';
echo '<td>'.$row['orderno'].'</td>';
echo '<td>'.$row['total'].'</td>';
echo '<td>';
if($row['status'] == "sold")
{
echo '<select name = "status[]">';
echo '<option value = "sold" selected>Sold</option>';
echo '<option value = "cancelled">Cancelled</option>';
echo '</select>';
}
else
{
echo '<select name = "status[]">';
echo '<option value = "sold">Sold</option>';
echo '<option value = "cancelled" selected>Cancelled</option>';
echo '</select>';
}
echo '</td>
echo </tr>';
}
if(isset($_POST['status']))
{
//sample only
echo "You change orderno ".$orderno_here." with the
total of ".$total_of_order." into ".$selected_status_of_orderno_here;
}
表中有很多记录且选择相同
如何获取所选选择的值
最佳答案
根据你的问题,无论我理解什么,我假设你正在从页面中的表单之类的标签获取数据。如果是这种情况,您就知道哪个值被更改以反射(reflect)在 db 中。所以你可以从中得到选择的选择。 您可以通过以下代码检查更改:
if(isset($_POST['element'])){
//if this block executed, the <element> named element is changed
}
如果您在代码中使用的不是这种情况,请忽略此答案。
关于php - 获取表中更改后的选择的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29176998/