Jump to content


multiple search php/mysql

  • Please log in to reply
No replies to this topic

#1 miz_luvly@hotmail.com

  • Members
  • PipPipPip
  • Advanced Member
  • 41 posts

Posted 25 April 2006 - 03:45 PM

hi guyz

i 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.


this 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:

if (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%' " .
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;
while($row = mysql_fetch_array($result, MYSQL_BOTH))
echo "<tr><td>".$row['ACCOUNT_NO']."</td>
echo "</table>";

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users