buff logo

Search Profiles By Location

Back to Index

roles)||in_array('authenticated user',$user->roles)) { print "Hello $user->name

"; $field = db_fetch_object(db_query("SELECT DISTINCT(fid), type, title, page, visibility FROM {profile_fields} WHERE name = '%s'", $name)); $fields = array(); $result = db_query('SELECT name, title, type, weight FROM {profile_fields} WHERE fid != %d AND visibility = %d ORDER BY weight', $field->fid, PROFILE_PUBLIC_LISTINGS); while ($record = db_fetch_object($result)) { $fields[] = $record; } $mysearchtype=""; $output=""; $psearch="CHECKED"; $tsearch=""; $locationsearch=''; $locationtype=''; $regionsearch=''; if (isset($_POST['searchlocationform'])) { $mysearchtype=$_POST['searchlocationform']; $_SESSION['mysearchtype']=$mysearchtype; } else { if (isset($_SESSION['mysearchtype'])) { $mysearchtype=$_SESSION['mysearchtype']; } } if (isset($_SESSION['regionsearch'])) { $regionsearch=$_SESSION['regionsearch']; } if (isset($_POST['regionsearch'])) { $regionsearch=$_POST['regionsearch']; $_SESSION['regionsearch']=$regionsearch; } if (isset($_SESSION['locationsearch'])) { $locationsearch=$_SESSION['locationsearch']; } if (isset($_SESSION['locationtype'])) { $locationtype=$_SESSION['locationtype']; } if (isset($_POST['locationsearch'])) { $locationsearch=$_POST['locationsearch']; $_SESSION['locationsearch']=$locationsearch; } if (isset($_POST['locationtype'])) { $locationtype=$_POST['locationtype']; $_SESSION['locationtype']=$locationtype; } if ($mysearchtype == 'searched') { if ($locationtype == "postcodearea") { $output.="Searching for people with a postcode like ".$locationsearch."
\n"; $result = pager_query("SELECT {profile_values}.uid, {profile_values}.value, {users}.name FROM {profile_values} LEFT JOIN {users} ON {users}.uid={profile_values}.uid WHERE ( ( {profile_values}.fid=9 ) and ( {profile_values}.value like '%s%%' ) and ( {users}.name IS NOT NULL ) ) ORDER BY {users}.name", 10,0,NULL,$locationsearch); $output .= '

'; while ($account = db_fetch_object($result)) { // $output .= theme('profile_profile', user_load(array('uid' => $account->uid)), $fields); $output .= ""; } $output .= "
".theme('user_picture', user_load(array('uid' => $account->uid)))."".theme('username', user_load(array('uid' => $account->uid)), $fields)." ".$account->value."
".theme('pager', 10); } else { $psearch=""; $tsearch="CHECKED"; $output.="Searching for people with a town like ".$locationsearch."
\n"; $result = pager_query("SELECT {profile_values}.uid, {profile_values}.value, {users}.name FROM {profile_values} LEFT JOIN {users} ON {users}.uid={profile_values}.uid WHERE ( ( {profile_values}.fid=9 ) and ( {profile_values}.value like '%%%s%%' ) and ( {users}.name IS NOT NULL ) ) ORDER BY {users}.name", 10,0,NULL,$locationsearch); $output .= '
'; while ($account = db_fetch_object($result)) { // $output .= theme('profile_profile', user_load(array('uid' => $account->uid)), $fields); $output .= ""; } $output .= "
".theme('user_picture', user_load(array('uid' => $account->uid)), $fields)."".theme('username', user_load(array('uid' => $account->uid)), $fields)." ".$account->value."
".theme('pager', 10); } } if ($mysearchtype=='searchedregion') { $output.="Searching for people in region : ".$regionsearch."
\n"; $result = pager_query("SELECT {profile_values}.uid, {users}.name, {regionspostcode}.postalarea, {regionspostcode}.regionname, {profile_values}.value FROM {profile_values} LEFT JOIN {users} ON {users}.uid={profile_values}.uid LEFT JOIN {regionspostcode} ON concat({regionspostcode}.postalarea,' -')=concat(trim(substring({profile_values}.value,1,2)),' -') WHERE ( ({profile_values}.fid=9 ) and ({regionspostcode}.regionname ='%s' ) and ({users}.name IS NOT NULL ) ) ORDER BY {users}.name", 10,0,NULL,$regionsearch); $output .= '
'; while ($account = db_fetch_object($result)) { // $output .= theme('profile_profile', user_load(array('uid' => $account->uid)), $fields); $output .= ""; } $output .= "
".theme('user_picture', user_load(array('uid' => $account->uid)))."".theme('username', user_load(array('uid' => $account->uid)), $fields)." ".$account->value."
".theme('pager', 10); } $searchregion="
"; $output.="
Enter location to search for
Search By Postcode region
Search By town
Search by Region
".$searchregion."

See map
"; $result = db_query("SELECT {profile_values}.value FROM {profile_values} WHERE ( ( {profile_values}.fid=4 ) and ( {profile_values}.uid = $user->uid ) )"); $output .= '
'; $accval = db_fetch_object($result); $output.='
'; echo $output; } else { global $user; drupal_goto('node/3472'); } ?>
Click here to read more - if you want to be a part of ITB, sign up it is free to sign up and chat on line