Page 1 of 1

PLEASE help with search-query.

Posted: Wed Aug 11, 2004 5:22 pm
by potato
Hello,

can somebody say why this litlle script isn't working.

Code: Select all

if(isset($_POSTї'land'])){ 
    if($_POSTї'land'] == "3"){ 
        $sql .= " AND land = '%'"; 
    } else { 
        $sql .= " AND land ='".$_POSTї'land']."'"; }}
		
if (!empty($_POSTї"genre"])){ 
    if($_POSTї'genre'] == ""){ 
       
    } else { 
        $sql .= " AND band_subgenre ='".$_POSTї'genre']."' OR band_hoofdgenre = '".$_POSTї'genre']."'"; }}



$allevents = mysql_query($sql);
Thanx

Posted: Wed Aug 11, 2004 7:02 pm
by feyd
could you give us a few details of what you're trying to do?

just as a quick debugging thing, echo $sql just before the call to mysql_query()... and add "or die(mysql_error());" to the query call so it looks like this:

Code: Select all

mysql_query($sql) or die(mysql_error());

Posted: Thu Aug 12, 2004 12:17 pm
by potato
I try to make a search query for my bands table.
I have on my form a radio group, called 'land', and i have a select list called 'genre'.

Now, in my table, i do a search with the fields: land, band_hoofdgenre & band_subgenre.

You can see the page here.

I did what you said to echo my query. Here's an example:
SELECT * FROM bands WHERE band_active = 1 AND land ='2' AND band_subgenre ='Funk' OR band_hoofdgenre = 'Funk'
He gives me with this query artists with the h-genre or s-genre as funk, BUT also off the other country, not only from country 2 like i demand.

If i make a query where i only demand the users of country 2, without a genre, it works fine, and shows all the artists from country 2.

Please see the example page to try and see the query's, it's really strange.

Anyway, thanx for your answer, i really appreciate it.

Posted: Fri Aug 13, 2004 7:06 am
by potato
anybody?