Re: mysql question
| From: | peter a | Date: | Sun, 20 Oct 2002 18:04:48 +0000 |
| Subject: | Re: mysql question | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-120678@lists.php.net to get a copy of this message | ||
put your categoies in and array and build
your query something like this
foreach ($categoris as $val) {
$where .= "|| category='$val', ";
}
// strip the && and , in the beginning and end
$where = eregi_replace("^||","",$where);
$where = eregi_replace(",$","",$where);
$query = "select * from images where $where";
$result = mysql_query($query);
something like that.
/peter a
At 2002-10-20 19:54, Donahue Ben wrote:
>I have some images in my database, and they are put
>into certain categories. So what i have in my
>database is a table called images and a table called
>categories. My question is I want to retrieve images
>by selected categories the user chooses. So if there
>are a total of five categories, the user chooses two
>categories to views images, it will select those
>images only by the two categories the user selected.
>How can I do this with just submitting one query
>instead of submitting two queries? In both the image
>table and category table there is a unique id. So the
>image in the image table can reference the category in
>the category table.
>
>Ben D.
>
>__________________________________________________
>Do you Yahoo!?
>Y! Web Hosting - Let the expert host your web site
>http://webhosting.yahoo.com/
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php