我想在更改下拉列表中的选项时更新数据库的值。更新后,ctrl重定向回订单页面。现在更新可以正常工作了,但是无法返回到订单页面。为此,我使用了以下代码。
orders.php中的代码
<select name="order_status" onchange="update(this.value,<?php echo $row['orders_id'];?>)">
<option value="1" <?php if($row['orders_status']=='1'){ ?>selected="selected"<?php } ?>>In process</option>
<option value="2"<?php if($row['orders_status']=='2'){ ?>selected="selected"<?php } ?>>Processed</option>
<option value="3"<?php if($row['orders_status']=='3'){ ?>selected="selected"<?php } ?>>Dispatched</option>
</select>
<script>
function update(vals,order){
window.location="index.php?main_page=orders&val="+vals+"&id="+order;
}
</script>
<?php
if(($_REQUEST['id']) && ($_REQUEST['val'])){
$manufacturers = $db->Execute("update orders set orders_status = '{$_REQUEST['val']}'
where orders_id ='{$_REQUEST['id']}'");
if($manufacturers == '1'){
zen_redirect(zen_href_link('orders', '', $request_type));
}
}?>
发布于 2012-05-07 11:41:04
您的代码中有几个问题:
if(orders == '1'){ zen_redirect(zen_href_link('orders','',$request_type));}
您可能只使用zen_redirect行替换它,而不使用if()语句,因为您将进行重定向。
https://stackoverflow.com/questions/10335456
复制相似问题