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
https://forums.phpfreaks.com/topic/268058-advance-search/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.