Jump to content

Archived

This topic is now archived and is closed to further replies.

miz_luvly@hotmail.com

multiple search php/mysql

Recommended Posts

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.

thanx


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:
<?php

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%' " .
"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>";
?>

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.