Ok, so basically I have data I have added to an html table and a save button. I want this button to submit the data in the table to a php function so that I can modify my mysql database using the data. I have the tools to modify the database, as long as I can get the data. However, I have no clue how to do this. What is the best way to accomplish this?
3条回答 默认 最新
- duanchuang1935 2012-06-06 13:38关注
In Addition to what @John Conde said, for every record presented in the table, you should create it's respective hidden field i.e. a
<input type="hidden"... />
Considering that tables have rows and columns, I will make some assumptions:- I will assume that the rows are equivalent to the data you have on a per record basis
- That the columns are the fields you will update with data on a per record basis
Going on this assumption (let me assume 3 fields i.e. 3 columns and 2 records)
Field 1 Field 2 Field 3 Row 1 a b c Row 2 d e f
For each of these we'll create corresponding input fields in the form we'll create to contain the submit button like so:
<form action="" method="post"> <!--Row 1--> <input type="hidden" name="field_1[]" value="a" /> <input type="hidden" name="field_2[]" value="b" /> <input type="hidden" name="field_3[]" value="c" /> <!--Row 2--> <input type="hidden" name="field_1[]" value="d" /> <input type="hidden" name="field_2[]" value="e" /> <input type="hidden" name="field_3[]" value="f" /> <!-- more rows if they exist --> <input type="submit" name="my_btn" value="POST IT!" /> </form>
On the PHP side, you could then process the form fields, like so:
foreach($_POST["field_1"] as $id=>$field1_value){ $field2_value = $_POST["field_2"][$id]; $field3_value = $_POST["field_3"][$id]; ....... }
Hope this helps
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥15 乌班图ip地址配置及远程SSH
- ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
- ¥15 PSPICE制作一个加法器
- ¥15 javaweb项目无法正常跳转
- ¥15 VMBox虚拟机无法访问
- ¥15 skd显示找不到头文件
- ¥15 机器视觉中图片中长度与真实长度的关系
- ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
- ¥15 java 的protected权限 ,问题在注释里
- ¥15 这个是哪里有问题啊?