plexus Posted November 15, 2008 Share Posted November 15, 2008 Just a quick one. Got the following php script to extract out 'actualtag' from URL input as follows: http://www.website.dev/tag/actualtag <?php $url = $HTTP_SERVER_VARS["REQUEST_URI"]; list($trash, $directory, $tag) = split('[/]', $url);?> Next, I have an sql query to lookup table 'entry_keywords' for the text 'actualtag' (or whatever that it entered in the URL). Using a 'LIKE %$tag%' will cause any character that matches 'actualtag' to display the results. Question: 1. Is there anyway to do an exact match? (i.e. if you entered actual, no results will be displayed. it must be actualtag) 2. The table 'entry_keywords' consist of many other keywords (i.e. movies video trailer ... and many more), seperated by space. Is there anyway to match any of the keywords? For example, if keyword 'movies' or 'video' or 'trailer' is entered, it'll display the result accordingly, but subjected to exact matching as stated above. Hope it's not too confusing Quote Link to comment https://forums.phpfreaks.com/topic/132781-mysql-exact-match-with-php-script/ Share on other sites More sharing options...
xtopolis Posted November 15, 2008 Share Posted November 15, 2008 1) WHERE column = '$tag'; 2) Are you saying you have a table with a column that has data like: [sELECT `keywords` FROM `entry_keywords`] "movies video trailer" <-- what I think you're saying (returns 1 row) instead of: <-- what I want you to be saying "movies" "video" "trailer" (returns 3 rows) If the first one is yours, you should have a lookup table im thinking. It is never a good idea to store delimited data in a row afaik. Post your structure if that doesn't answer your questions.. Quote Link to comment https://forums.phpfreaks.com/topic/132781-mysql-exact-match-with-php-script/#findComment-690591 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.