5
Here is code of my search.inc.php if anyone would like to use it (may contain vulnerabilities!)
//thanks http://www.frxoops.org/modules/smartsection/item.php?itemid=179
function profile_search ($queryarray, $andor, $limit, $offset, $userid) {
global $xoopsDB;
// création de la requête
$sql = "SELECT * FROM (".$xoopsDB->prefix("users")." join ".$xoopsDB->prefix("profile_profile")." on ".$xoopsDB->prefix("users.uid")."=".$xoopsDB->prefix("profile_profile.profile_id").") where uid>0 ";
// $sql .= " WHERE uid>0 ."";
if ( $userid != 0 ) {
$sql .= " AND uid=".$userid." ";
}
if ( is_array($queryarray) && $count = count($queryarray) ) {
$sql .= " AND ((uname LIKE '%$queryarray[0]%' OR user_intrest LIKE '%$queryarray[0]%' OR bio LIKE '%$queryarray[0]%' OR city LIKE '%$queryarray[0]%' OR club LIKE '%$queryarray[0]%' OR bussines LIKE '%$queryarray[0]%')";
for($i=1;$i > $count;$i++){
$sql .= " $andor " ;
$sql .= "(uname LIKE '%$queryarray[$i]%' OR user_intrest LIKE '%$queryarray[$i]%' OR bio LIKE '%$queryarray[$i]%' OR city LIKE '%$queryarray[0]%' OR club LIKE '%$queryarray[0]%' OR bussines LIKE '%$queryarray[0]%')" ; } $sql .= ") " ;
}
$sql .= "ORDER BY uid DESC" ; // si condition de tri
$result = $xoopsDB->query($sql,$limit,$offset);
// création du tableau des résultats
$ret = array();
$i = 0;
while($myrow = $xoopsDB->fetchArray($result)){
$ret[$i]['image'] = "images/mymodule.gif";
$ret[$i]['link'] = "userinfo.php?uid=".$myrow['uid'].""; // lien sur la page qui affichera le texte
$ret[$i]['title'] = $myrow['uname'];
//$ret[$i]['time'] = $myrow['created'];
//$ret[$i]['uid'] = $myrow['uid'];
$i++;
}
return $ret;
}
?>
city, club, bussines are custom fields made with profile module. Modify it to your needs.