I have a form that was generated with the help of loops (I made it so I could select how many record sets I wanted to add at that time) So now I have this form that will display between 1 and 12 sets of text boxes (html) each with a value that is generated by the php script It works just fine.
Now, that generated form must pass entered data to the next script that will add the form feilds into the database. This is where I am stuck. I got to the point to add fields to the database then did not have no clue where the loops would fit in.
I am thinking that since I have 3 fields in each row that I would create a loop for each one of those to match its name.
Right now I basicly have this in the form:
When the form is generated it spits out something like this (html view)Code:<? echo " <input type="text" name="abox$i"><br> <input type="text" name="bbox$i"><br> <input type="text" name="cbox$i"><br> "; ?>
Got it? I know its confusingCode:<input type="text" name="abox1"><br> <input type="text" name="bbox1"><br> <input type="text" name="cbox1"><br> <input type="text" name="abox2"><br> <input type="text" name="bbox2"><br> <input type="text" name="cbox2"><br> <input type="text" name="abox3"><br> <input type="text" name="bbox3"><br> <input type="text" name="cbox3"><br>
But the big on is getting this stuff into the database with the help of loops.
Here is the database stuff I got right now, I just need to know where to put the loops
Thanks in advance!Code:<? // define the loops $a = 1; // counts the number of "abox's" $b = 1; // counts the number of "bbox's" $c = 1; // counts the number of "cbox's" // database functions $db_name = "photos"; $table_name = "data"; $connection = @mysql_connect("localhost, xxxxx, xxxxx") or die ("cannot connect"); $db = @mysql_select($db_name, $connection) or die ("cannot select"); $sql = " INSERT INTO $table_name(set_id, locate, name) VALUES (\"$abox\", \"$bbox\", \"$cbox\") "; $result = @mysql_query($sql, $connection) or die ("cannot connect"); ?>





Reply With Quote