Page 1 of 1

parse multi-select input field

Posted: Mon Sep 22, 2008 2:41 pm
by wescrock
Hey all,

So, I have found how to echo the results of an input of a multi-select input field... but I cant seem to get it to go to the db...

here is all my code:
HTML Page (form)
<label>Subcategory:</label>
<?php
$result_category = @mysql_query("select id_lookup_category_, parent, category from wfbiblio.lookup_category where parent = 0");
print "<select multiple=\"true\" name=\"subcategory[]\" size=\"6\">\n";
while ($row = mysql_fetch_assoc($result_category)){
$id_lookup_category_ = $row['id_lookup_category_'];
$category = $row['category'];
print "<option value=$id_lookup_category_>$category\n";
}
print "</select>\n";
print "</p>\n";
?>
PHP page:
$id_lookup_subcategory=$_POST['subcategory'];
foreach ($id_lookup_subcategory_ as $subcategory){
$sql = "insert into wfbiblio.category_link (id_category_link_parent_, id_citation_, id_lookup_category_)
values ('$last_citation_id', '$last_id', '$subcategory')"; echo $sql;
$result = mysql_query($sql) or die (mysql_error()); }
can anyone see what is wrong with this code?

thanks all,
Wes

Re: parse multi-select input field

Posted: Mon Sep 22, 2008 5:37 pm
by josh
1) dont use error supression
2) output your query and compare the data in the query to what you would expect the data to be.
3) if you dont already see your mistake then post the query here so we can have atleast some idea of whats going on