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
birrd
Forum Newbie
Posts: 6 Joined: Mon Dec 01, 2008 10:47 am
Post
by birrd » Sun Dec 07, 2008 8:32 am
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">
novice4eva
Forum Contributor
Posts: 327 Joined: Thu Mar 29, 2007 3:48 am
Location: Nepal
Post
by novice4eva » Sun Dec 07, 2008 8:48 am
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].')';