开发者

Posting jquery appended input boxes to MYSQL

We have a very large form and we are posting the data to mysql using $_POST, but we have 2 complex sections in the form w开发者_如何学运维here we need your help.

HTML markup of form

<label>Customer Name</label>  
<input type="text" size="50" name="name" />
<label>Education</label>
<input type="text" size="50" name="class" />
<input type="text" size="50" name="board" />
<input type="text" size="50" name="subjects" />
<input type="text" size="50" name="aggregate" />
<label>Payment Plan</label>
     <ul id="fields"></ul>

We are appending following to #fields using jquery

<li><input type="text" size="30" name="date" /> <input type="text" size="30" name="amount" /> </li>

Now we would like your help with the following problems...

  1. How to post education details to mysql table? - using php serialise?
  2. how to post appended input boxes to mysql's tbl.paymentplan?


If you've populated the fields using jquery (date & amount) and it's on the form, a simple "Submit" button which posts to a PHP page that handles the insert into the database should work fine.

Nothing complex about it. I use jquery to pre-load form data all the time like that.

If you want to avoid doing a postback entirely, and want to do that through jquery as well, you can. Once the data is loaded into the DOM and the form displays it you can do with it what you want.


Algorithm

  • use mysql_fetch_field to know all attributes name from your table
  • if attribute does not exist in current table then update table via php like below
  mysql_query("ALTER TABLE paymentplan
    ADD date CHAR(30) AFTER subject,
    Add payment CHAR(30) AFTER date");
  • and then insert the data the way u want.

Reference

mysql fetch field

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜