yami007 Posted October 4, 2009 Share Posted October 4, 2009 this is my code : <?php if(isset($_GET['query'])) { $query = "SELECT * FROM messages WHERE name LIKE '%{$_GET['query']}%' OR message LIKE '%{$_GET['query']}%' "; $result_set = mysql_query($query); while ($result = mysql_fetch_array($result_set)) { echo $result['name'].'<br />'; echo $result['message'].'<br />'; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/176485-what-should-i-add-to-my-basic-search/ Share on other sites More sharing options...
mikesta707 Posted October 4, 2009 Share Posted October 4, 2009 what to add depends on what results you want to get. How do you want to change your search query Quote Link to comment https://forums.phpfreaks.com/topic/176485-what-should-i-add-to-my-basic-search/#findComment-930314 Share on other sites More sharing options...
yami007 Posted October 4, 2009 Author Share Posted October 4, 2009 ah sorry, forgot the main issue what i need is when user type in something like "creed2" the query gets the the word "creed" and so on Quote Link to comment https://forums.phpfreaks.com/topic/176485-what-should-i-add-to-my-basic-search/#findComment-930317 Share on other sites More sharing options...
mikesta707 Posted October 4, 2009 Share Posted October 4, 2009 Im not sure exactly what you want to do? Do you want to strip numbers from strings? or just strip the number two? or also search for creed as well as creed2? can you perhaps explain a little better or provide more examples Quote Link to comment https://forums.phpfreaks.com/topic/176485-what-should-i-add-to-my-basic-search/#findComment-930318 Share on other sites More sharing options...
yami007 Posted October 4, 2009 Author Share Posted October 4, 2009 search for creed as well as creed2? can you perhaps explain a little better or provide more examples Quote Link to comment https://forums.phpfreaks.com/topic/176485-what-should-i-add-to-my-basic-search/#findComment-930319 Share on other sites More sharing options...
jon23d Posted October 5, 2009 Share Posted October 5, 2009 You need to escape your data prior to using it in a query. Use mysql_escape_string on any user input prior to its insertion in SQL. If you don't know why, google 'sql injection', but do it no matter what! Quote Link to comment https://forums.phpfreaks.com/topic/176485-what-should-i-add-to-my-basic-search/#findComment-930464 Share on other sites More sharing options...
yami007 Posted October 5, 2009 Author Share Posted October 5, 2009 thanks for this, is helpful but what i need actually is if the word "creedon" is not found on the db table, then if the word "creed" is found, get the results. what function do i need to do that? Quote Link to comment https://forums.phpfreaks.com/topic/176485-what-should-i-add-to-my-basic-search/#findComment-930705 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.