yanivkalfa Posted January 21, 2008 Share Posted January 21, 2008 Anywyas . i am trying to search from my data base something that the user sent with form its simple search though its nothing preset i mean i need to search from a table and i dont want to search the exact word. for EG the dude typed in metalica ban and in my database is shows as metalica i want a quary that will search for the most close resualt that it can i can use $query = "SELECT * FROM files LIMIT $limitvalue, $limit WHERE name = '$_POST[search]'"; i mean this is do able but if the dude have written metalica ban and in my intery i have metalica only will it still choose metalica ? well if it wont will someone please show me a better way of doing so . would realy help me . thanks in advanced BTW i have no idea why it brought up this poll. Quote Link to comment https://forums.phpfreaks.com/topic/87040-searching-in-data-base/ Share on other sites More sharing options...
pocobueno1388 Posted January 21, 2008 Share Posted January 21, 2008 Your query would look something like this <?php $search = mysql_real_escape_string($_POST['search']); $query = "SELECT * FROM files WHERE name LIKE '%$search%' LIMIT $limitvalue, $limit"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/87040-searching-in-data-base/#findComment-445165 Share on other sites More sharing options...
GingerRobot Posted January 21, 2008 Share Posted January 21, 2008 Even with the above, if a user were to enter 'metalica ban' the query would not find rows matching 'metalica'. One way around this is to explode the search term by the space, and search the database to see if any of the words match. However, that would then lead you into issues of relevant results. You may wish to look into full text searching. Quote Link to comment https://forums.phpfreaks.com/topic/87040-searching-in-data-base/#findComment-445203 Share on other sites More sharing options...
yanivkalfa Posted January 21, 2008 Author Share Posted January 21, 2008 well so how do i do it then . well with the link its nice but if your saying its still wont help so what way would work then ? Quote Link to comment https://forums.phpfreaks.com/topic/87040-searching-in-data-base/#findComment-445662 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.