Forum Moderators: coopster
Can anybody tell me how to use
mySQL WHERE IN function in PHP
// this is HTML code
<select size="6" name="Categories[]" multiple>
<option value="0" selected>[ -- Select Categories --]
<?
while ($items=mysql_fetch_array($result))
{
?>
<OPTION VALUE="<? echo $items['CategoryID']?>"><? echo $items['Categories']?></OPTION>
<?
}
?>
</SELECT>
///what will be a query using IN function of mySQL
Thanks in Advance
Be sure to read Marcia`s WebmasterWorld Welcome and Guide to the Basics [webmasterworld.com] post.
Have a look at the documentation for Comparison Operators [mysql.com] at mysql.com.
To execute MySQL queries in PHP use the mysql_query [php.net] function.
Andreas
something like this maybe?
$wherein = "select CategoryID,Categories from table where CategoryID in (1,3,5,7)";
$result = mysql_query($wherein);
while ($items=mysql_fetch_array($result))
{
?>
<OPTION VALUE="<? echo $items['CategoryID']?>"><? echo $items['Categories']?></OPTION>
<?
}
?>
</SELECT>