November 17th, 1999, 04:34 PM
-
I have a double problem. I'm trying to set up a survey form, but a) I need to load data into more than 1 table in the database, and can't get that to work;
and b) some of the survey fields have to allow for multiple entries (series of checkboxes with "check all that apply"), and the only one that seems to be making it into the database is the last item selected.
PHP script code:
$query = "INSERT INTO programs VALUES('$program_name', '$program_district', '$program_address', '$program_city', '$program_state_prov', '$program_zip', '$program_phone', '$program_fax', '$program_email', '$program_url', '$contact_name', '$contact_title', '$contact_address', '$contact_city', '$contact_state_prov', '$contact_zip', '$contact_phone', '$contact_fax', '$contact_email', '$form_name', '$form_phone', '$form_email')";
$result = MYSQL_QUERY($query);
$query= "INSERT INTO info VALUES('$prog_descr_text', '$purpose')";
$result = MYSQL_QUERY($query);
--end code
Also, is $query some kind of reserved term? I've been able to insert into a single table using $query, but when I tried to differentiate between the 2 MYSQL_QUERY statements with different variables, that wouldn't work either.
Any help anyone can provide is greatly appreciated.
Thanks in advance!
November 18th, 1999, 09:12 AM
-
There's no telling why your second query doesn't work unless you check the mysql error to see what mysql is complaining about. After the second query add this line:
print mysql_error();
As far as multiple selects go, you need to give the input an array variable name. e.g.:
name="myvar[]"
That way each selected item's value will be placed into the $myvar array starting at index 0.
November 18th, 1999, 11:08 AM
-
Thanks! I've got stuff going into both tables now; my problem is still the checkboxes/arrays, but that's a question for the MySQL forum.