I've tried to post on a few other forums for information on how to write a very simple search script that will allow multiple search options to search a mysql database. I have a script written that searches by a users last name, but I want to also offer the option to search by a users city or state. I have a couple radio buttons in the html, but don't have any idea how to manipulate the php. Any suggestions? Here's the code I have:
<?php
include('config.php');
$SQL_FROM = 'adr';
$SQL_WHERE = 'last';
?>
<?php
$searchq = strip_tags($_GET['q']);
$getRecord_sql = 'SELECT * FROM '.$SQL_FROM.' WHERE '.$SQL_WHERE.' LIKE "'.$searchq.'%"';
$getRecord = mysql_query($getRecord_sql);
if(strlen($searchq)>0){
// ---------------------------------------------------------------- //
// AJAX Response //
// ---------------------------------------------------------------- //
echo '<ul>';
while ($list = mysql_fetch_array($getRecord)) {?>
<li><a href="runners2.php?name=<?php echo urlencode($list['first'].' '.$list['last']); ?>"><?php echo $list['last']; ?> <small><?php echo $list['first']; ?></small><small><?php echo $list['city']; ?></small><small><?php echo $list['age']; ?></small></a></li>
<?php }
echo '</ul>';
?>
<?php } ?>
The bottom portion is an AJAX response that makes an auto suggestion according to what letters you type. Thanks in advance!