Hello everybody!!!
I am trying to make a site where a user can select various checkboxes and see all the products of the categories he has checked.
What i have done is create as many chkboxes as the categories are

<input type="checkbox" name="ch1" value="movies" />
<input type="checkbox" name="ch2" value="music" />

Then in my php code i wrote....

if ($ch1 == 'movies') {
$where .= " and A.OB_MOVIES= true ";
}
if ($ch2 == 'music') {
$where .= " and  A.0B_MUSIC= true ";
}
Then i pass the query string as a variable
$request_string = "from " . G_DB_PREFIX . "OBJECTS A, 
        " . G_DB_PREFIX . "OBJECT_TR B, 
        " . G_DB_PREFIX . "TRANSLATION C
       where A.OB_ID=B.OTR_OBJECTID and B.OTR_LANG='" . G_LANG . "'
       and A.OB_PRODUCTID=C.TR_REFID and C.TR_LANG='" . G_LANG . "' and
       C.TR_REFNAME='PRODUCTID' $where";

As you may understand MOVIES, MUSIC are boolean values in my mysql database.
But instead of turning back all the products that belong to those two categories (in case we check both) turns nothing. I understand that the reason is because the query searches for products that belong to both categories.
What kind of expression do i have to use to achieve what i want?
Probably i have to use a checkbox array for that?
The code works just fine if i only check one categorie.
I am really newbie to PHP so if you can give me a hand i will be grateful.
Thanx in advance

use $_POST,$_POST instead of $ch1,$ch2 if the method of form is post..,
and check this

$where="";
if ($_POST['ch1']== 'movies') {
$where = " and A.OB_MOVIES= 'true' ";
}
if ($_POST['ch2']== 'music') {
$where = " and A.OB_MUSIC= 'true' "; //instead of [B][U]0[/U][/B]B_MUSIC its zero not O
}

%^^%Murtada%^^%

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.