Jump to content

Ignore "The" if in string.


only1perky

Recommended Posts

Hi guys,

 

I am querying my database depending on the first letter of the field using:

 

mysql_select_db($database_connuser, $connuser) or die;
    $query = "SELECT * FROM drinking WHERE venue LIKE '{$Letter}%'"; 

$numresults=mysql_query($query);
$numrows=mysql_num_rows($numresults);

 

 

What I would like to happen is if the first word of $row['venue'] is THE then to ignore it and move on to the next word.

 

Can someone help me out?

Link to comment
https://forums.phpfreaks.com/topic/142947-ignore-the-if-in-string/
Share on other sites

You should be able to do it in the MySQL query.

 

mysql_select_db($database_connuser, $connuser) or die;
    $query = "SELECT * FROM drinking WHERE REPLACE(venue, 'The ', '') LIKE '{$Letter}%'"; 

$numresults=mysql_query($query);
$numrows=mysql_num_rows($numresults);

 

I think that'll work.

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.