October 23, 200917 yr Ok well i've made this simple search you may use to search a database and display results Search.php <?php mysql_connect(localhost,root,"") or die ("can't connect to database"); mysql_select_db(test); $find = $_POST['search']; if(isset($_POST['submit'])){ if($find == ""){ echo"<b>No Search Term Entered</b>"; }else{ $sql = "SELECT * FROM table_name WHERE Fname LIKE '%$find%' OR Lname LIKE '%$find%' OR email LIKE '%$find%'"; $sql2 = mysql_query($sql) or die(mysql_error()); if(mysql_num_rows($sql2) == 0){ echo"<b>No Results Found</b>"; }else{ while($results = mysql_fetch_assoc($sql2)){ $fname = stripslashes($results['Fname']); $lname = stripslashes($results['Lname']); $email = stripslashes($results['email']); echo"".$fname."<br /> ".$lname." <br /> ".$email.""; } } } echo " <form method=\"POST\" action=\"$_SERVER["PHP_SELF"]\"> <p> <input type=\"text\" value=\"Keyword\" name=\"search\" title=\"Search\" onclick=\"if(value='Keyword'){value=''}\"><br /> <input type=\"submit\" name=\"submit\" value=\"Search\"> </p> </form> "; ?> And that should do the trick i have not tested it yet so if you catch a mistake above let me know and i'll fix it now just create the database and the tables then you have a simple search you can build off of. you can select from as many tables you like and search everything inside your database enjoy:clapping:
Create an account or sign in to comment