Page 1 of 1

Results from checkboxes

Posted: Sun Dec 07, 2008 8:32 am
by birrd
Hi,

Does anyone know how I can use foreach or forloop to get any selected checkboxes results and how can I query mysql to echo for the multiple values? :?:

Code: Select all

 
<input type="checkbox" name="rating[]" value="1">
<input type="checkbox" name="rating[]" value="2">
<input type="checkbox" name="rating[]" value="3">
<input type="checkbox" name="rating[]" value="4">
<input type="checkbox" name="rating[]" value="5">
 

Re: Results from checkboxes

Posted: Sun Dec 07, 2008 8:48 am
by novice4eva
HTML :

Code: Select all

 
 <input type="checkbox" name="rating" value="1">
 <input type="checkbox" name="rating" value="2">
 <input type="checkbox" name="rating" value="3">
 <input type="checkbox" name="rating" value="4">
 <input type="checkbox" name="rating" value="5">
 
PHP:

Code: Select all

 
foreach($_REQUEST['rating'] as $val)
    echo $val;
 
SQL:

Code: Select all

 
$SQL = 'SELECT ....  FROM .... WHERE rating in ('.implode(',',$_REQUEST[''rating].')';