Jump to content

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>";
?>
Link to comment
https://forums.phpfreaks.com/topic/8375-multiple-search-phpmysql/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.