Jump to content

Can someone please help with a search statement?


srhino

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,

 

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.