I have my code didn't work properly, if I add additional condition on where clause like AND ServiceID = '$searchService ID' the form didn't display. here are my codes. Please help..Thanks
this is my database
searchClient.ph p
clientSearch.ph p
Thanks for advance...Hope you can help me guys...
-ghop'z
this is my database
Code:
CREATE TABLE `client` ( `ClientID` int(11) NOT NULL AUTO_INCREMENT, `ClientFirstName` varchar(50) NOT NULL, `ClientLastName` varchar(50) NOT NULL, PRIMARY KEY (`ClientID`) ) CREATE TABLE `service` ( `ServiceID` varchar(14) NOT NULL, `ClientID` int(11) DEFAULT NULL, )
searchClient.ph p
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title></title>
<link rel="stylesheet" type="text/css" href="style.css" />
<link type="text/css" href="themes/base/ui.all.css" rel="stylesheet" />
<link rel="stylesheet" type="text/css" href="jquery.autocomplete.css" />
<script type="text/javascript" src="jquery-1.3.2.js"></script>
<script type="text/javascript" src="ui/ui.core.js"></script>
<script type='text/javascript' src='jquery.autocomplete.js'></script>
<script type="text/javascript" src="jquery.watermarkinput.js"></script>
<script type="text/javascript">
$().ready(function() {
$("#nput").autocomplete("clientSearch.php", {
width: 260,
matchContains: true,
selectFirst: false
});
});
jQuery(function($){
$("#nput").Watermark("Search Client");
});
</script>
</style>
</head>
<body>
<form action="" method=POST>
<input type="text" id="nput" name="nput">
<input type=submit name=search value=search>
</form>
<?php
include "config/opendb.php";
if(isset($_POST['search']))
{
$nput = $_POST['nput'];
$searchServiceID = substr($nput, -11);
$nput = strtok($nput,",");
$serviceSelectQuery = "SELECT ServiceID, b.ClientID, ClientFirstName, ClientLastName, ClientAddress, ClientEmail, ClientContactNumber, ClientCompanyName, TIN, ClientCity, ClientCountry, ClientBirthDate, ClientMobileNumber
FROM service a, client b WHERE a.ClientID = b.ClientID AND CONCAT(ClientFirstName,' ',ClientLastName) = '$name' AND ServiceID = '$searchServiceID'";
$res1 = mysql_query($serviceSelectQuery) or die("Error1:clientSearch.php--->".mysql_error());
while(list($serviceID, $clientFirstName, $clientLastName)=mysql_fetch_array($res1))
{
echo "<form action='createReservationForm.php' method='POST'>
<fieldset>
<h3>Contact Info</h3>
<table>
<tr>
<td>
<label for = 'serviceID'>ServiceID:</label>
<input type='text' id='serviceID' name='serviceID' value='$serviceID' readonly/>
</td>
<td>
<label for = 'clientFirstName'>FirstName:</label>
<input type='text' id='clientFirstName' name='clientFirstName' value='$clientFirstName' readonly/>
</td>
<td>
<label for = 'clientLastName'>LastName:</label>
<input type='text' id='clientLastName' name='clientLastName' value='$clientLastName' readonly/>
</td>
<table>
<tr>
<td>
<input type=submit class=button name='submit' value='Add New Transaction'>
</td>
<td>
<input type=reset class=button name='reset' value='Reset'>
</td>
</tr>
</table>
</form>";
}
}
include "config/closedb.php";
?>
</body>
</html>
Code:
<?php
include 'config/opendb.php';
$q = ucwords($_GET['q']);
if(!$q) return;
$query = mysql_query("SELECT ClientFirstName, ClientLastName, ServiceID FROM client a, service b
WHERE a.ClientID = b.ClientID AND ClientFirstName LIKE '%$q%' OR ClientLastName LIKE '%$q%' OR ServiceID LIKE '$q%' ORDER BY ClientLastName LIMIT 5");
while($row=mysql_fetch_array($query))
{
$clientFirstName = $row['ClientFirstName'];
$clientLastName = $row['ClientLastName'];
$serviceID = $row['ServiceID'];
echo $clientFirstName.' '.$clientLastName.", ".$serviceID."\n";
}
?>
Thanks for advance...Hope you can help me guys...
-ghop'z
Comment