miz_luvly@hotmail.com Posted April 25, 2006 Share Posted April 25, 2006 hi guyzi need help with keyword search. I can search by customer name but i want to search by customer name and/or town and/or post (using text box for each). can someone please guide me on how to extend the search criteria. thanxthis what I currently have:html form:...<td colspan=2> search by Customer Name: <br><input type=text name='keywords' size=30 maxlength=255></td>php script:<?phpif (isset($_GET['keywords'])) { $sql = "select * from customer_table WHERE CUSTOMER_NAME LIKE '".$_GET['keywords']."'%"; $result = mysql_query($sql); if (!$result) { echo 'Could not run query: ' . mysql_error(); } echo '<a href="report_search.php">back to search page</a>'; echo "<table border=1 class='rep' width ='100%' " . "cellspacing='0'"."callpadding='5'>\n"; echo "<tr><th class='searchHeader'><caption><b> Search Results for </b></caption> </th></tr>\n"; echo "<tr><td><b>Account No:</td><td><b>Customer Name:</td><td><b>Town:</td><td><b>Post Code:</td></tr>"; if ($result and !mysql_num_rows ($result)) { echo "<tr class='row1'><td>No results found that match the "; echo "search term(s) '<strong>" . $_GET['keywords'] . "</strong>'"; echo $sql; } else { while($row = mysql_fetch_array($result, MYSQL_BOTH)) { echo "<tr><td>".$row['ACCOUNT_NO']."</td> <td>".$row['CUSTOMER_NAME']."</td> <td>".$row['ADDRESS4']."</td> <td>".$row['POST_CODE']."</td></tr>"; }}} echo "</table>";?> Quote Link to comment https://forums.phpfreaks.com/topic/8375-multiple-search-phpmysql/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.