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
https://forums.phpfreaks.com/topic/76054-dynamically-create-table-rows-as-needed/
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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.