(no one seems to have seen this attachment to previous thread so will repost here).
In a mysql "kids" table I want each kid to have their
own record. I want their record to contain that kid's unique
(autoincremented id), their name (entered in through a form), and the id
of their father (last column - the value of which is tied into the id in
the father table). The input form the father fills out has fields for up
to 5 kids - fields are named kidname1, kidname2, kidname3, etc. There is
also a field to enter the total number_kids (so I will know how many
kids' names to expect.
I want to build a loop (below) to store the kids' names that are
entered. Every time I go through the loop for another kid (up to
number_kids),I want to say to build that kidname field from the string
"$kidname" and concatinate the number, then find this resulting string
variable's entered value and store that name in the database. So if I'm
through the loop the third time I want to construct the variable name to
say "$kidname3" and then evaluate it as "Sam" and store that value. Will
this code do that?
For ($counter = 1, $counter <= $number_kids, $counter++ ) {
$kidname = '$kidname'
$kidname .= $counter
$insertstmt = "insert into kids (kidid, kidname, memberid) values (null,
$kidname, last_insert_id()) ;
open connection to db and insert, etc.
}
By the way, if I open more than one connection in my program, do I need
to
"mysql_free_result($sql_resultX);" each time, in maybe reverse order to
how I opened them? Do I need to free one before I open another?