multiple selects into mysql database
| From: | dbarber | Date: | Thu, 24 Aug 2000 17:59:17 +0000 |
| Subject: | multiple selects into mysql database | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-13476@lists.php.net to get a copy of this message | ||
Hello,
I'm trying to do something that has turned relatively complicated for a
novice like myself. Snippets of code follow.
Explanation:
I have an include that is populating a multiple select list from an array.
Then, the person selects an option or two from that list.
They then submit the selections via POST to the next form.
The next form then does an insert into a database.
everything works to the POST. Those items that are not multiple select
lists get put into the database. The problem is in passing
the variable to the second page and in identifying how to call
that variable in the insert statement.
excerpts from my scripts:
##### Array Include File
<?
$disciplineOption = array(
"C/C++",
"CORBA");
// do work
for($i=0; $i < count($disciplineOption); $i++)
{
{
print("<option value=\"$disciplineOption\" ");
}
print(">{$disciplineOption[$i]}\n");
}
?>
##### The Multiple select box itself with call to include file
//discipline
print(" <TR> \n");
print(" <TH ALIGN = LEFT>Discipline </TH> \n");
print(" <TD> \n");
print(" <!-- BEGIN dynamic HTML - Categories multi-select list -->
\n");
print("<select name=\"discipline[]\" multiple size=5> \n ");
include("/usr/local/genpage/include/discipline.php");
print(" </select> \n");
print(" <!-- END dynamic HTML --> \n");
print(" </TD></TR> \n");
##### The insert into SQL (the insert works except for $discipline[$z]
for($z=0; $z<count($discipline); $z++) echo $discipline;
$insquery = "insert into position(id,title,salary,discipline,sector,description
,location) values
('$a','$b','$c','$discipline[$z]','$e','$f','$g')
";
$insresult = mysql_query($insquery, $dbLink);
##############################
I'm pretty sure the problem is because I don't know how to isolate the
multiple $discipline[] variable coming through. If anyone can help I'd
really appreciate it.
thanks,
Dan