Results from checkboxes

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
birrd
Forum Newbie
Posts: 6
Joined: Mon Dec 01, 2008 10:47 am

Results from checkboxes

Post 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">
 
User avatar
novice4eva
Forum Contributor
Posts: 327
Joined: Thu Mar 29, 2007 3:48 am
Location: Nepal

Re: Results from checkboxes

Post 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].')';
 
Post Reply