pudge1 Posted August 3, 2010 Share Posted August 3, 2010 function Search($search_term) { $user = '***'; $pass = '***'; $dbname = '***'; $search_term = mysql_real_escape_string($search_term); $connection = mysql_connect('localhost',$user,$pass); mysql_select_db($dbname, $connection); $sql = "SELECT Note_ID FROM Notes WHERE Keywords LIKE '%$keywords%'" $query = mysql_query($sql, $connection); } So I am kinda new to MySQL so I don't know it that well, how will the results of this search be displayed? Thank you so much if you help Quote Link to comment https://forums.phpfreaks.com/topic/209691-mysql-results-display/ Share on other sites More sharing options...
Pikachu2000 Posted August 3, 2010 Share Posted August 3, 2010 Using just that code, they won't be displayed at all. Quote Link to comment https://forums.phpfreaks.com/topic/209691-mysql-results-display/#findComment-1094805 Share on other sites More sharing options...
pudge1 Posted August 3, 2010 Author Share Posted August 3, 2010 That is what I meant to ask. How do I display them? Quote Link to comment https://forums.phpfreaks.com/topic/209691-mysql-results-display/#findComment-1094817 Share on other sites More sharing options...
Pikachu2000 Posted August 3, 2010 Share Posted August 3, 2010 Oh, now I see where you were going with it. How many records do you expect to be returned? More than one? Quote Link to comment https://forums.phpfreaks.com/topic/209691-mysql-results-display/#findComment-1094827 Share on other sites More sharing options...
awjudd Posted August 3, 2010 Share Posted August 3, 2010 Another thing is, in query you have $keyword whereas whenever you reference it outside of the query it is $search_term (and you never assign $search_term to $keyword). So the query won't ever return what you want it to Single row expected: $arr = mysql_fetch_array ( $query ); print_r ( $arr ); // Display all information returned echo $arr [ 'Note_ID' ]; // Echo only the 'Note_ID' which is returned Multiple rows returned: while ( $arr = mysql_fetch_array ( $query ) ) { print_r ( $arr ); // Display all information returned echo $arr [ 'Note_ID' ]; // Echo only the 'Note_ID' which is returned } Hope this helps. ~juddster Quote Link to comment https://forums.phpfreaks.com/topic/209691-mysql-results-display/#findComment-1094840 Share on other sites More sharing options...
pudge1 Posted August 4, 2010 Author Share Posted August 4, 2010 Thank you so much exactly what I wanted. Quote Link to comment https://forums.phpfreaks.com/topic/209691-mysql-results-display/#findComment-1094907 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.