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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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