Jump to content

Can someone please help with a search statement?


Recommended Posts

Hi,

  I am trying to use a search box on my website to find a tournament name and a last name or first name when entered into the search form. I have the seasrch working when you put in the event name but I can not figure out how to pull up by lastname.

 

 

here is my code

$search = $_GET['searchFor'];
    $query = "SELECT tourname, lastname from events where tourname like '%$search%' or lastname like '%search%'";

    $result = mysql_query($query) or die('Could not query database at this time');

    echo "<h1>Search Results</h1><br><br>\n";

    if (mysql_num_rows($result) == 0)
    {
        echo "<h2>Sorry, no events were found with '$search' in them.</h2>";
    } else
    {
        echo "<h2>Events matching '$search':</h2><br><br>";
        while($row=mysql_fetch_array($result, MYSQL_ASSOC))
        {
            $tournid = $row['tournid'];
            $tourname = $row['tourname'];
		$lastname = $row['lastname'];
           
            echo "<a href=\"index.php?content=showevent&id=$tournid\">$tourname</a><br>\n";
           
        }
    }

 

Thanks,

 

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.