pazza86 Posted January 2, 2008 Share Posted January 2, 2008 hi everyone. I'm a bit of a self taught noob who is learning the ropes, but im having some problems with a script that im writing. What I am trying to do is enter a search term in a field (movie name) on one page and compare the field against data in the database (whether it be spelt right or not) and the next page display the corresponding data on one page. I believe that i have the page that displays the information correct I just need some help with the query. Please see the below mentioned script exerts and give a noob a hand : $result = mysql_query("SELECT * FROM movie WHERE mname = '%$mnsearch%'"); The above line when the submit button is clicked displays the table header information with no data in any cell. $result = mysql_query("SELECT * FROM movie WHERE mname LIKE '%$mnsearch%'"); This line displays the table fine, the only problem being that it selects all of the data in the table, even when the movie name is spelt correctly. Any help would be great. cheers Quote Link to comment https://forums.phpfreaks.com/topic/84084-solved-help-a-noob-please/ Share on other sites More sharing options...
lovesmith Posted January 2, 2008 Share Posted January 2, 2008 Try this $result = mysql_query("SELECT * FROM movie WHERE mname LIKE '%".$mnsearch."%'"); This will display all the result that contains the string $mnsearch holds. Quote Link to comment https://forums.phpfreaks.com/topic/84084-solved-help-a-noob-please/#findComment-428001 Share on other sites More sharing options...
pazza86 Posted January 2, 2008 Author Share Posted January 2, 2008 thanks for the help. for some reason though that is doing the same thing as before - displays the data correctly, but it displays the entire contents of the table instead of matching the string ??? Quote Link to comment https://forums.phpfreaks.com/topic/84084-solved-help-a-noob-please/#findComment-428004 Share on other sites More sharing options...
Daniel0 Posted January 2, 2008 Share Posted January 2, 2008 All content as in all rows or all content as in all columns for a single/couple (of) row(s)? Quote Link to comment https://forums.phpfreaks.com/topic/84084-solved-help-a-noob-please/#findComment-428006 Share on other sites More sharing options...
pazza86 Posted January 2, 2008 Author Share Posted January 2, 2008 rows on content - it displays correctly, it is just displaying the incorrect data ??? Quote Link to comment https://forums.phpfreaks.com/topic/84084-solved-help-a-noob-please/#findComment-428008 Share on other sites More sharing options...
lovesmith Posted January 2, 2008 Share Posted January 2, 2008 rows on content - it displays correctly, it is just displaying the incorrect data ??? First you type the search item in the text box then press search button and it is posted to another location rite? Try to find first whether $mnsearch is empty or not Do like this where you post the form echo "<script> alert('".$mnsearch."'); </script>"; i m sure you get empty message box. Your problem occurred because $mnsearch is an empty string. Quote Link to comment https://forums.phpfreaks.com/topic/84084-solved-help-a-noob-please/#findComment-428012 Share on other sites More sharing options...
pazza86 Posted January 2, 2008 Author Share Posted January 2, 2008 ok u are looking at the worlds biggest noob. The problem all along (and thanks to lovesmith for prompting the validation code) was the fact that i was missing an equals sign in the form code for the name attribute . Quote Link to comment https://forums.phpfreaks.com/topic/84084-solved-help-a-noob-please/#findComment-428024 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.