Jump to content

php multiple select box


project3

Recommended Posts

Ok I have a multiple select box and want to insert the results into the db.

 

right now it only inserts the last selected option. Im sure I need to turn that

into an array and get it like this $theval[0]; $theval[1]; 

 

but I'm not sure how you would know how many values are in the array.

 

then how would i insert that into the db all in the same field.

Link to comment
https://forums.phpfreaks.com/topic/93387-php-multiple-select-box/
Share on other sites

You could implode the array on insert then explode it when reading the value.

 

I like pipe '|' since you hardly ever use it but there is no magic reason I chose it.

 

<?php

$insval = implode('|', $theval);

// do insert using $insval

 

// get back to the array

$theval = explode('|', $row['theval']);

 

?>

Archived

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

×
×
  • Create New...

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.