the query is correct but why form didn't display?whats wrong?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ghopz
    New Member
    • Jul 2010
    • 11

    the query is correct but why form didn't display?whats wrong?

    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
    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>
    clientSearch.ph p
    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
  • code green
    Recognized Expert Top Contributor
    • Mar 2007
    • 1726

    #2
    $searchServiceI D is probably empty

    Comment

    • ghopz
      New Member
      • Jul 2010
      • 11

      #3
      Originally posted by code green
      $searchServiceI D is probably empty
      Hi code green,

      I tested it and $searchServiceI D is not null... it has the correct value..any comments? i dont get my error... i already checked it many times but i cant see whats my error..

      thanks,
      ghop'z

      Comment

      • code green
        Recognized Expert Top Contributor
        • Mar 2007
        • 1726

        #4
        Code:
        while(list($serviceID, $clientFirstName, $clientLastName)=mysql_fetch_array($res1))
        list actually returns void so I can't see this looping at all

        Comment

        • ghopz
          New Member
          • Jul 2010
          • 11

          #5
          Originally posted by code green
          Code:
          while(list($serviceID, $clientFirstName, $clientLastName)=mysql_fetch_array($res1))
          list actually returns void so I can't see this looping at all
          Hi code green,

          I don't get it. i test my query to my MySQL browser and the query is correct. can you explain it to me?Please?

          Thanks,
          ghop'z

          Comment

          Working...