Jump to content

Dynamically create table rows as needed


jimlawrnc

Recommended Posts

I have a form with a table. Each table row has a ID= "some number".  I have 4 rows and might need to create more. how can i do this in php?  To go along with this, When I hit the submit buton, I then need all the table row data saved to a db i have. I can insert 1 line with out a issue.  I also made sure the table row name="" fields are unique.  ex.

 

<table>
<tbody>
<tr id="0">
<td>Client:</td>
<td> <input size="30" name="Client"></td>
<td>Hours:</td>
<td><input size="10" name="Hours"></td>
<td>Mileage:</td>
<td><input size="10" name="Mileage">

</td>
<td>Billable:</td>
<td> <input name="Billable" value="Yes" type="checkbox"></td>
<td>Non-Billable:</td>
<td> <input name="NoBillable" value="Yes" type="checkbox"> </td>
<td>Date:</td>
<td><input type="text" name="datBegin" size="10">
 
<script language=javascript>
var basicCal = new calendar("FIELD:document.frm.datBegin");
basicCal.writeCalendar();
</script></td>
</tr>

<!--- Add a few more rows here --->
<tr id="1">
<td>Client:</td>
<td> <input size="30" name="Client1"></td>
<td>Hours:</td>
<td><input size="10" name="Hours1"></td>
<td>Mileage:</td>
<td><input size="10" name="Mileage1">
</td>
<td>Billable:</td>
<td> <input name="Billable1" value="Yes" type="checkbox"></td>

<td>Non-Billable:</td>
<td> <input name="NoBillable1" value="Yes" type="checkbox"> </td>
<td>Date:</td>
<td><input type="text" name="datBegin1" size="10">
 
<script language=javascript>
var basicCal = new calendar("FIELD:document.frm.datBegin1");
basicCal.writeCalendar();
</script></td></tr>

 

This repeats on 2 more times 

 

So to recap. 

 

I need to

A. create another table row as needed via button.

B. capture all the data on the form and submit to the DB

C. check for empty data if so stop at that point assuming thats all the data at this time.

D. loop through the data and send it on its way.

 

One more Q.  can i have 2 mysql_query  statements in the same php form?  it seems if i try to perform 2 of these then the page doesn't work correctly. 

 

To top things off, I would like to generate a table with the data that was submitted  on a report page after submitting.

 

Thank you to all

 

If you require more info i'll provide what i have. I also have a live site i can test this all out on and if needed give you access to the page

Link to comment
Share on other sites

I have 4 rows and might need to create more. how can i do this in php?

 

You have four fields[/i]. And it would be poor design to warrant creating more. There is a link in my signiture to a free php book, within the database section of that book is a sub section on database nromalization techniques. You should read it.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.