doumi4676 2015-07-15 08:44
浏览 26

autosubmit将值下拉到数据库中

i'm trying to auto submit the value of drop down menu using onchange=this.form.submit() into database but i couldn't make it work. can anyone please help me. any suggestions will be highly appreciated.

here is the code:

<? 
require_once ('database.php');
?>

<form action="" method=post>
<select name="assignee"  onchange="this.form.submit()">
<option value="0">Unassigned</option>   
        <?
        $find_selected = mysql_query("select assign_to from orders where id = $id");
        $asignee =mysql_fetch_row($find_selected);
        $list=mysql_query("SELECT id, full_name from user where username <> 'root' and nature = 3");
        while($row_list=mysql_fetch_assoc($list)){
        ?>
        <option value="<? echo $row_list['id']; ?>"<? if($row_list['id']== $asignee['0']){ echo "selected"; } ?>><? echo $row_list['full_name'] ?></option>
        <?
        }
        mysql_free_result($list);
        mysql_free_result($find_selected);
        ?>
</select>
</form>
<?php 

if(isset($_POST['submit'])){

$sql = "UPDATE `orders` SET `assign_to` =  '{$_POST['assignee']}' WHERE `id` = '$id' ";
mysql_query($sql) or die(mysql_error());    
}


?>
  • 写回答

1条回答 默认 最新

  • douyun3022 2015-07-15 09:09
    关注
    <?php 
    
    if(isset($_POST['assignee'])){
    
    $sql = "UPDATE `orders` SET `assign_to` =  '{$_POST['assignee']}' WHERE id=$id";    
    mysql_query($sql);
    }
    
    ?>
    

    You just defined your query but didn't executed it

    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?