doukangbin9698 2015-07-17 13:20
浏览 33

在MySQL查询中使用javascript run select选项

I have a select box which is linked through JS. I'm trying to make it so that the option chosen is essentially saved, so that when 'refresh attendees' is clicked, only the attendees from the selected group get refreshed.

select box

<select name="users" onChange="showYes(this.value); showNo(this.value); showUn(this.value);" style="font-size: 14px; font-family: open-sans,sans-serif; font-weight: 700; line-height: 17px;" id="attactivity">
          <option value="">Select Activity</option>
          <option value="CMA">CMA</option>
          <option value="CM2">CM2</option>
          <option value="CMB">CMB</option>
          <option value="CPM">CMP</option>

MySQL

    $refreshatt = mysql_real_escape_string($_POST['refreshatt']);
    $attactivity= mysql_real_escape_string($_POST['attactivity']);
    // See if that product name is an identical match to another product in the system

    $sql = mysql_query("UPDATE stats SET attend='0' WHERE activity='attactivity'");
    header("location: admin-page.php"); 
    exit();
}
?>

Right now, it is not getting anything as attactivity, so no group is being refreshed. Any suggestions?

As a heads-up: I have tried the query stating a group (i.e. CMA, CM2, etc) and the everything works. It seems to be just getting the value of 'attactivity'

  • 写回答

1条回答 默认 最新

  • dotaer1993 2015-07-17 13:27
    关注

    Assuming you are posting your form data correctly, your issue is your query. You have insert a literal attactivity instead of the variable.

    $sql = mysql_query("UPDATE stats SET attend='0' WHERE activity='attactivity'");
    

    vs.

    $sql = mysql_query("UPDATE stats SET attend='0' WHERE activity='$attactivity'");
    

    Additional Recommendations:

    评论

报告相同问题?

悬赏问题

  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大