Jump to content

Archived

This topic is now archived and is closed to further replies.

blanktarget

does anyone know the best way,

Recommended Posts

I have form data where one field is a multiple select. I\'ve set up a table for the multiple select data-\'group\', I have a table for the rest of the data-\'listing\'. I have a third table-\'link\' which has the primary keys from each of the other tables, group_id and listing_id, because I need each client\'s listing, which is phone, name, etc. to correspond with all of the groups that they select in the form.

 

I have this layyed out as a script but it seems messy and I don\'t know if it will work as the database grows

 

after connection and form validation:

 

insert into table listing (column_1, etc) values ($name, etc)

select * from listing order by \'listin_id\' limit 0, 1 //to get the last row?

 

and then insert the groups selected with the listing_id for reference into the \'link\' table. Somehow this seems like it\'s almost there. That multi select is killing me, this should be easy.

Share this post


Link to post
Share on other sites

When you have a multiple select, give it an array name, like \'group[]\'

 

When you process the form

 

[php:1:491fe48a91]<?php

$groups = $_POST[\'group\'];

 

foreach ($groups as $group) {

# insert a group record for value $group

}

?>[/php:1:491fe48a91]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.