Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search form

Status
Not open for further replies.

monasa

IS-IT--Management
Jun 27, 2004
41
CA

I want to have a form that permet to search by location or by name in a database. how can I do this with a simple form.

M.N
 
Roadmap:
1. have an input box for the search term
2. have 2 radio buttons, one for location, the other for name
3. Receiving script checks what to search

Code:
<form action="search.php" method="post">
Search for <input type="text" name="searchfor"><br />
<input type="radio" name="column" value="location">In location<br />
<input type="radio" name="column" value="name">In name<br />
<input type="submit" value="GO">
</form>
In the PHP just make your SQL statements according to what's posted.
 
for example a gamesearch:

Code:
<?php
$k = $_POST['keywords']; //textbox name

$q = mysql_query("SELECT gid, title FROM search WHERE keywords LIKE '%$k%'") or die(mysql_error());
    while(list($gid,$t) = mysql_fetch_row($q)){
        echo "<a href=game.php?gid=$gid>$t</a>"."<br>";
    }
?>

does this help?


Regards,

Martin

Gaming Help And Info:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top