View Full Version : select box to array

03-19-2007, 09:51 AM
I have a multiple select box named

<select name=schools[] multiple>

now my php to retrieve thse is

foreach ($school as $k=>$v)
$sql=$sql."reason like '".$v."%'";
if ($n>0){
$sql=$sql." or ";

now instead of adding each school to the sql it's just writing it out as
array instead of the school name from the select -- what am i doing wrong?

03-19-2007, 10:21 PM
if (!isset($_POST['submit']))
echo '
<form action="" method="POST">
<select name="num[]" size="5" multiple>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<input type="submit" name="submit" value="submit">
if (isset($_POST['num']))
foreach ($_POST['num'] as $value) {$sql_array[] = "'" . $value . "'";}
$sql = 'SELECT * FROM table WHERE num IN(' . implode(',', $sql_array) . ')';
echo $sql;
echo 'you did not select any numbers';

03-20-2007, 07:58 AM
will this work with request also?
as that is what i did but it doesn't seem to work