PLEASE help with search-query.

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

Post Reply
User avatar
potato
Forum Contributor
Posts: 192
Joined: Tue Mar 16, 2004 8:30 am
Location: my lovely trailer, next to the big tree

PLEASE help with search-query.

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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());
User avatar
potato
Forum Contributor
Posts: 192
Joined: Tue Mar 16, 2004 8:30 am
Location: my lovely trailer, next to the big tree

Post 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.
User avatar
potato
Forum Contributor
Posts: 192
Joined: Tue Mar 16, 2004 8:30 am
Location: my lovely trailer, next to the big tree

Post by potato »

anybody?
Post Reply