Jump to content

MySQL Results Display


pudge1

Recommended Posts

  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 :)

Link to comment
https://forums.phpfreaks.com/topic/209691-mysql-results-display/
Share on other sites

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 :P

 

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.