PDA

View Full Version : hi how to make multiple selection - php I have this...


nanny
07-05-2007, 06:53 AM
Hi I have a dynamic menu that DJ helped me to make sticky but now I want to make sticky with multiple selections for another form.

<select name="classtypeid">
<option value="" <?php if (!(strcmp("", $_POST['classtypeid']))) {echo "SELECTED";} ?>>Select Category</option>
<?php
do {
?>
<option value="<?php echo $row_cattype['classtypeid']?>"<?php if (!(strcmp($row_cattype['classtypeid'], $_POST['classtypeid']))) {echo "SELECTED";} ?>><?php echo $row_cattype['categorytype']?></option>
<?php
} while ($row_cattype = mysql_fetch_assoc($cattype));
$rows = mysql_num_rows($cattype);
if($rows > 0) {
mysql_data_seek($cattype, 0);
$row_cattype = mysql_fetch_assoc($cattype);
}
?>
</select>


I would appreciate any input, no matter how I try it will only work on edit form, not inserting data.

davidj
07-05-2007, 09:26 AM
Mmm not sure what your wanting here. Can you go into more detail like a scenario.

I have to picture it in my head before i can work it out... which contradicts me being a programmer coz I'm using the wrong side of my brain to do it apparently!

nanny
07-05-2007, 10:33 PM
Hi davidj
I have a large form for a viewer to fill out for an advertisement. I have 3 select menus and thanks to you, they are now staying selected on resubmit if the viewer has made errors.
The difference with this form is that I am wanting those select menus to be used to select multiple choices not just one.
select menu 1: location
select menu 2: industry
select menu 3: category

On the form where a viewer does not pay they can not get this advantage of selecting multiple.
I have tried the implode and using [] in the name of the select menu, and yes it will allow me to select multiple but on the resubmit of the form, all selections are gone. Very annoying when it is a large form.
Hope you have another brilliant idea.
Cheers.........

nanny
07-05-2007, 11:33 PM
Hi I just tried placing another select menu in the form with the same name as it would need to be the same foreign key for the database.
e.g. the select menu I gave in the first post I put in again but it will only allow me to give a selection for one. I thought I could do that but how would you if it needs to have the same id????
I have seen it in some forms....... maybe it doesn't go into the same..........I think I got it ..I need to make another table with a different name and id and the same insert values and then call it into the database. For searching I would then need to place the new table in there as well.

Am I right??? Not making sense????
I will give it a go and let you know unless you have a better idea, like the multiple selection which is a better solution.

nanny
07-06-2007, 12:39 AM
It worked although I would still like to learn how to make multiple stick and into database.
Cheers