Hey all,
I am trying to insert some items into a mysql database but am having some issues. (no this isnt totally a mysql question) =p I have a dynamic form that is being generated where I need the data from that form inserted into the mysql database. The form will vary depending on what the user wants out of it.. it may have a varying number of columns and rows with each intersection making a text field.. just like excel. I am trying to get the headers to insert and have it just loop through the headers and add a new header each time into the database. Right now I am just trying to get two headers to show up.. header_top1 and 2. if I do a standard insert without the "for" loop, then the insert works, but only inserts the last header name entered. if I run it as you see below, then I can print this and see everything showing up correctly, but nothing inserts at all. Any ideas? Thanks!
$tmpquery1 = "INSERT INTO ".$tableName["tctable"]."(name,added_by,header_top1,header_top2) VALUES('$name','$added_by')";
for($k = 0; $k < count($header_top); )
{
$header_topA = $header_top[$k];
$tmpquery1 .= ",'$header_topA'";
$k++;
}
$tmpquery1 .= ")";