Search String Help: Display Specific Letter

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
palmere
Forum Newbie
Posts: 17
Joined: Fri Mar 19, 2004 5:33 pm

Search String Help: Display Specific Letter

Post by palmere »

Hi all,

I'm in the process of converting another script that uses PHP to access a mySQL database from a search script to a script that displays results by a specified letter (i.e. display all artists that beging with a, b, etc). Here's the search string that the script currently uses:

Code: Select all

if ($dvd_search != "") { $dvd_search_string = " WHERE ". $dvd_search_type . " like "%" . $dvd_search . "%""; }
I would like to change the $dvd_search variable to a $_GET['beta'] variable, but i keep getting parse errors when I make the change. I'm willing to bet that I'm overlooking something drastically simple. Thanks a million guys.

E
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

Try:

if (!empty($_GET['beta'])) {
$dvd_search_string = ' WHERE '. $dvd_search_type . ' like "%' .$_GET['beta']. '%"';
}
palmere
Forum Newbie
Posts: 17
Joined: Fri Mar 19, 2004 5:33 pm

Post by palmere »

Like a charm.

All I had to do was drop the first %. Thanks much.

E
Post Reply