I have a form that searches a database for info (I'm pretty sure this isn't a database issue, though, because the returned query runs smoothly from MySQLQueryBrowser). The form has a select box for the type of info the user is looking for (artist, album, or label) and a textfield for the search string. It's an AJAX suggest form so there is no submit button.
My problem is that when 'artist' is selected the query runs perfectly well but when either of the other two search types are selected it doesn't. I have the php returning the built query with every keypress and I have run each independantly and they work fine.
I'm not sure what I'm missing and I hope that someone had sharper eyes than I.
Here's the relevant code:
Code: Select all
$st = $_GET['st'];
switch($st)
{
case "artist":
$query = "SELECT distinct
artist
FROM
recordings
WHERE
artist LIKE '".$searchString."%'
ORDER BY artist ASC
";
break;
case "title":
$query = "SELECT distinct
title
FROM
recordings
WHERE
title LIKE '%".$searchString."%'
ORDER BY title ASC
";
break;
case "label_year":
$query = "SELECT distinct
label_year
FROM
recordings
WHERE
label_year LIKE '".$searchString."%'
ORDER BY label_year ASC
";
break;
}
print("query: ".$query);
$sql = mysql_query($query);I'd really appreaciate any help.
Thanks,
b