View Single Post
Old 06-27-2008, 12:45 AM   #3 (permalink)
sarmenhb
The Addict
 
sarmenhb's Avatar
 
Join Date: Jan 2008
Location: los angeles
Posts: 255
Thanks: 39
sarmenhb is on a distinguished road
Default

Quote:
Originally Posted by delayedinsanity View Post
Assign them to an array, and loop through the array when you add the data to the table.

HTML Code:
<input type="text" name="row_data[]" value="" />
When you use [] in the input fields name value, it adds all data to an array of the same name. Then you could use a foreach or for loop to spin through them and add them to the database however you like.
-m

thanks but what if this is my code

HTML Code:
<input type="text" name="row_data[1]" value="" />
<input type="text" name="row_data[2]" value="" />
<input type="text" name="row_data[3]" value="" />
<input type="text" name="row_data[4]" value="" />
<input type="text" name="row_data[5]" value="" />
what kind of php do i use to loop through this and to the db?

would it look liek this? its just a guess

Code:
for($i=0;$i<count($row_data);$i++) {

$query = mysql_query("insert into table values(null,'$_POST['row_data[i]]'");
}
__________________
http://www.sarmenhb.com
Send a message via AIM to sarmenhb Send a message via MSN to sarmenhb Send a message via Yahoo to sarmenhb Send a message via Skype™ to sarmenhb
sarmenhb is offline  
Reply With Quote