| | |||||||
| |||||||
| |||||||
|
|
|
|
|
|
|
This will allow you to search you records in your database. It uses the LIKE string and looks for anything related and prints it. For example if you search for the letter "m" it would print all data fitting the catagory you gave it with the letter "m". [ the llama ] Update made 0a5-25-2001......the search string was not searchinng the entire fileds, only the first word of each record....the change had to do with the LIKE and % strings..... By : llama ###################################################################### # The LLama # =========================== # # Copyright (c) 2000 by The LLama (scripts@projectgis.org) # # Search Records In MYSQL # # This program is free software. ###################################################################### //This is the form I use to initiate the script (call this find.php) <form method=post action="search.php"> Search For: <p> User Name: <input type=text name=user size=25 maxlength=25> <p> Password: <input type=text name=passwd size=25 maxlength=25> <p> <input type=submit> </form> //search.php <? //You should now this but be sure to connect to your database or this is useless. :/ if ($user == "") {$user = '%';} if ($passwd == "") {$passwd = '%';} // $user and $passwd are the two column names I used. Change this to fit your database $result = mysql_query ("SELECT * FROM yourtable WHERE user LIKE '%$user%' AND passwd LIKE '%$passwd%' "); if ($row = mysql_fetch_array($result)) { do { PRINT "<b>User Name: </b> "; print $row["user"]; print (" "); print ("<br>"); PRINT "<b>Passwd: </b> "; print $row["passwd"]; print ("<p>"); PRINT "<b>FirstName: </b> "; print $row["firstname"]; print ("<p>"); } while($row = mysql_fetch_array($result)); } else {print "Sorry, no records were found!";} //The end result prints the username / passwd / firstname / lastname / ID / email //you will have to change these fields also to fit your needs ?>
More Search Code Articles |
| |
| |