Jump to content

PHP/MySQL SELECT most similar (help me)


TitusRevised

Recommended Posts

Is there an sql function to SELECT any rows in a table most similar to a field... like instead of SELECT * FROM table WHERE field LIKE '%$string%' which finds a row with keyword $string, so if $string is "hi my name is" but there isnt a row like but there is a row "hello my name is" it would pull that row because its most similar.

PHP example:
<?php
$string = trim(strip_tags(addslashes($_POST['usermsg'])));
$sql = mysql_query("SELECT * FROM table WHERE field = '%$string%");
// This finds me a row where field "field" has the $string in it exactly somewhere
?>
How can I make it so that if it's not exact it pulls out the row with the field "field" most similar to $string?

Your great wisdom and intelligence on the matter to assist me is appreciated greatly.
Link to comment
Share on other sites

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.