NaniG Posted September 6, 2012 Share Posted September 6, 2012 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. Quote Link to comment Share on other sites More sharing options...
Jessica Posted September 6, 2012 Share Posted September 6, 2012 The first thing you should do is fix the name of your function to search instead of serach. Secondly, start capturing errors, look at the examples on the manual. http://us2.php.net/mysql_query Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.