drisate Posted September 24, 2009 Share Posted September 24, 2009 Hey guys i need to create a function that tests if the first letter is found in a table... works great for the normal abc characters but ia m having a problem taking care of the special french characters This is what i got: function check_l($lettre, $categ){ if ($lettre == "a"){$str = "a, à, â"; }elseif ($lettre == "e"){$str = "e, é, è, ê"; }elseif ($lettre == "c"){$str = "c, ç"; }elseif ($lettre == "i"){$str = "i, î, ï"; }else{ $str = $lettre; } $explode = explode (', ', $str); foreach ($explode as $value){ $nb = $nb + @current(@mysql_fetch_assoc(@mysql_query("SELECT count(id) FROM page where LOWER(LEFT(titre,1)) = '$value' and publier = '1' and categ='$categ'"))); } return $nb; } The problem is that the title in the table is HTML encoded so the special character "à" for exemple would be equal to à. Now knowing that, the above LOWER(LEFT(titre,1)) would only see the first character of the HTML encoded "à" wich would be "&". How can i html_entity_decode the LOWER(LEFT(titre,1)) expression an easy and clean way? LOWER(LEFT(html_entity_decode(titre),1)) is not working ... Quote Link to comment https://forums.phpfreaks.com/topic/175397-html_entity_decode-in-sql/ Share on other sites More sharing options...
drisate Posted September 24, 2009 Author Share Posted September 24, 2009 I know i could simply do something like titre = '$value%' but if theres more then one word it would do a fals positive when it comes to show them in an other code Quote Link to comment https://forums.phpfreaks.com/topic/175397-html_entity_decode-in-sql/#findComment-924273 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.