乱世@小熊 2012-05-04 22:39 采纳率: 25%
浏览 71

前端mysql,删除一行

i'm creating a front end to view a mysql database with options to filter by certain criteria (such as age and sex) as well as options for deleting specific entries in the database.

i used this http://www.tizag.com/ajaxTutorial/ajaxxmlhttprequest.php as a guide to build everything.

so far this is what i have: view.php - authenticates user, creates basic html with input boxes in order to define the filters, a submit button, javascript function that reads the values from the input boxes and calls ajax.php, basic html to display results of mysql query.

ajax.php - connects to the mysql DB, gets the input values from view.php, builds the mysql query from the input values, creates a table of all the mysql query result which is displayed by view.php.

within each row of the mysql query result, i have an html input button which, onclick, calls a javascript function intended for deleting the specific row. so each row has it's own delete button. this delete function right now resides in view.php.

my intention, is that the delete js function will call another file, say delete.php and that delete.php will activate the mysql query to delete the specific row based upon which delete button was clicked.

the only part i don't have working correctly is how to pass the correct row ID to delete.php.

any thoughts?

  • 写回答

1条回答 默认 最新

  • weixin_33705053 2012-05-04 22:53
    关注

    In the onclick event of each button which is generated through php, store the row ID as the parameter of the function which sends that parameter to your delete.php.

    Example:

    In the php which generates each of your delete buttons:

    echo '<input type="button" value="Delete" onclick="delete('. $row_ID .')" />';
    

    Then just make the corresponding AJAX function delete(row_id) in your javascript which will pass that parameter as part of the request to your delete.php.

    评论

报告相同问题?

悬赏问题

  • ¥15 vue3+express部署到nginx
  • ¥20 搭建pt1000三线制高精度测温电路
  • ¥15 使用Jdk8自带的算法,和Jdk11自带的加密结果会一样吗,不一样的话有什么解决方案,Jdk不能升级的情况
  • ¥15 画两个图 python或R
  • ¥15 在线请求openmv与pixhawk 实现实时目标跟踪的具体通讯方法
  • ¥15 八路抢答器设计出现故障
  • ¥15 opencv 无法读取视频
  • ¥15 按键修改电子时钟,C51单片机
  • ¥60 Java中实现如何实现张量类,并用于图像处理(不运用其他科学计算库和图像处理库))
  • ¥20 5037端口被adb自己占了