From: snailaju <ad...@ya...> - 2007-04-29 17:04:41
|
this is the function i used in the userlib.php function search_hotel($offset = 0, $maxRecords = -1, $find = '', $type) { if ($find) { $mid = " where `hotel.nl_id` like ? and `hotel.hot_type` like ? and `hotel.nl_id` = `kr_node_location.nl_id`"; $bindvars = array('%'.$find.'%','%'.$type.'%'); } else { $mid = "where `hotel.nl_id` != `hotel.nl_id`"; $bindvars = array(); } $query = "select `hotel.hot_name`,`hotel.hot_id`,`hotel.hot_add`,`hotel.hot_type`, `kr_node_location.nl_name` from `hotel`,`kr_node_location` $mid order by `hotel.hot_name`"; $query_cant = "select count(*) from `hotel`"; $result = $this->query($query, $bindvars, $maxRecords, $offset); $cant = $this->getOne($query_cant, false); $ret = array(); while ($res = $result->fetchRow()) { $aux = array(); $aux["hotel.hot_name"] = $res["hotel.hot_name"]; $aux["hotel.hot_d"] = $res["hotel.hot_id"]; $aux["hotel.hot_add"] = $res["hotel.hot_add"]; $aux["hotel.hot_type"] = $res["hotel.hot_type"]; $aux["kr_node_location.nl_name"] = $res["kr_node_location.nl_name"]; $ret[] = $aux; } $retval = array(); $retval["data"] = $ret; $retval["cant"] = $cant; return $retval; } and this is where i call the function in the page,is this correct? if (isset($_REQUEST["search_hotel"])) { if (isset($_REQUEST["so"])) { $so = $_REQUEST["so"]; } else { $so = ''; } if (isset($_REQUEST["toi"])) { $toi = $_REQUEST["toi"]; } else { $toi = ''; } if (isset($_REQUEST["find_from"])) { $find_from = $_REQUEST["find_from"]; } else { $find_from = 0; } if (isset($_REQUEST["find_to"])) { $find_to = $_REQUEST["find_to"]; } else { $find_to = 0; } if (isset($_REQUEST["type"])) { $type = $_REQUEST["type"]; } else { $type = 0; } $smarty->assign('find_from', $find_from); $smarty->assign('find_to', $find_to); $smarty->assign('type', $type); if($find_from > $find_to){ $tmp = $find_from; $find_from = $find_to; $find_to = $tmp; } if($find_from == 0) $hotels = $userlib->search_hotel($offset, $numrows,$find_to, $type); else { for($i = $find_from; $i <= $find_to; $i++){ $hotels = $userlib->search_hotel($offset, $numrows, $i, $type); // <-- is this the correct way to used an array $hotels[]? } } } when i run this function, i get this result using this parameter: http://localhost/nbpl/test2.php?find_from=003&find_to=003&type=1*&so=Hotel&toi=info&search_hotel=Hotel+Search&numrows=10 Values: Array ( [0] => %003% [1] => %1*% ) // <-- what this massage mean?? $result is false $result is empty -- View this message in context: http://www.nabble.com/can-anyone-find-the-error-in-my-funtion--tf3666101.html#a10243511 Sent from the TikiWiki - User mailing list archive at Nabble.com. |