4
Ok, I'm having trouble getting this to work. Can you look at my code and let me know what I'm doing wrong? The first list is the table I want to pull from. The second is my search.inc.php file.
The database table:
CREATE TABLE `xoops_rr_rr` (
`id_rr` int(11) NOT NULL auto_increment,
`cuisine_rr` varchar(255) default NULL,
`dress_rr` varchar(255) default NULL,
`name_rr` varchar(255) NOT NULL default '',
`street_address_rr` varchar(255) default '',
`city_rr` varchar(50) default NULL,
`state_rr` varchar(255) NOT NULL default '',
`zipcode_rr` int(10) default '0',
`phone_rr` varchar(15) default NULL,
`email_rr` varchar(255) default '',
`url_rr` varchar(255) default NULL,
`dollar_rr` varchar(255) default NULL,
`food_qa_no_rr` int(3) default '0',
`food_qa_comment_rr` longtext,
`atmosphere__no_rr` int(3) default '0',
`atmosphere__comment_rr` longtext,
`service_no_rr` int(3) default '0',
`service_comment_rr` longtext,
`wine_list_rr` longtext,
`bar_rr` longtext,
`groups` varchar(255) default '',
`children` varchar(255) default '',
`noise_level_rr` varchar(255) default '',
`other_comments_rr` longtext,
`signature_usr_rr` varchar(255) default NULL,
`approved_rr` varchar(4) NOT NULL default 'No',
`date_rr` datetime NOT NULL default '0000-00-00 00:00:00',
PRIMARY KEY (`id_rr`)
) TYPE=MyISAM AUTO_INCREMENT=21 ;
______________________________________________
Here is my search.inc.php file:
function restaurant_search($queryarray, $andor, $limit, $offset, $userid){
global $xoopsDB;
$sql = "SELECT id_rr,name_rr FROM ".$xoopsDB->prefix("rr_rr")."";
if ( is_array($queryarray) && $count = count($queryarray) ) {
$sql .= " WHERE ((name_rr LIKE '%$queryarray[0]%'";
for($i=1;$i<$count;$i++){
$sql .= " $andor ";
$sql .= "(name_rr LIKE '%$queryarray[$i]%')";
}
$sql .= ") ";
} // end if
$sql .= "ORDER BY id DESC";
$query = $xoopsDB->query("SELECT COUNT(*) FROM ".$xoopsDB->prefix("rr_rr")." WHERE id_rr>0");
list($numrows) = $xoopsDB->fetchrow($query);
$result = $xoopsDB->query($sql,$limit,$offset);
$ret = array();
$i = 0;
while($myrow = $xoopsDB->fetchArray($result)){
$ret[$i]['image'] = "images/url.gif";
$ret[$i]['link'] = "index.php?start=".($numrows-$myrow['id_rr']);
$ret[$i]['name_rr'] = $myrow['name_rr'];
$ret[$i]['uid'] = "";
$i++;
}
return $ret;
}
?>
______________________________________________
I want to be able to search on all the fields.
Any ideas?