Jump to content

Recommended Posts

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 :)

Link to comment
https://forums.phpfreaks.com/topic/132781-mysql-exact-match-with-php-script/
Share on other sites

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..

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.