Jump to content

Advance Search


NaniG

Recommended Posts

Hi to all,

 

      Am not able to get the correct results with search code. Here is the my search code

 

public function serachTable($table, array $data)
    {
  $fields = array_keys($data);
  $values = array_values($data);
  $count = count($fields);
  $item = "";
      for($i = 0; $i < $count; $i++)
       {
	 if($count > 1 && $count - 1 != $i)
	  {
	    if(is_string($values[$i]))
		  {
	        $item .=  $fields[$i] . " LIKE " . "'{%$values[$i]%}' AND ";

		  }
		  else
		  {
		   $item .=  $fields[$i] . " = " . "'{%$values[$i]%}' AND ";
		  }
	  }
	  else
	  {
	    if(is_string($values[$i]))
		  {
	        $item .=  $fields[$i] . " LIKE " . "'{%$values[$i]%}'";
		  }
		  else
		  {
		   $item .=  $fields[$i] . " = " . "'{%$values[$i]%}'";
		  }
	  }
   }
  $sql = "SELECT * FROM {$table} WHERE {$item}";
  $this->Command = mysql_query($sql, $this->load);
  $this->CallBack = mysql_affected_rows();
}

 

and here is the my PHP code

 

$db = new testCore();
$dataSearchInfoArray = array (
'TIC_NAME' => $ticket_name,
				'TICKET_TYPE' => $ticket_type,
				'PRODUCT_ID' => $ticket_product,
				'PROD_VER_ID' => $ticket_version,
				'SERVICE_NAME' => $ticket_service,
				'CUST_ID' => $_SESSION['cust_id']
			);
$db->serachTable('tb_tickets', $dataSearchInfoArray);
$numTicket=mysql_num_rows($db->Command);
if($numTicket>0)
		{
			while($rowTicket=mysql_fetch_object($db->Command))
			{ ?>
....... HTML Code ......
<?php}
}?>

when i tried with above code, am not getting any record.

 

Please help me out from these issue.

 

Link to comment
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.