function display_directory($id, $table){
global $db_database, $db;
mysql_select_db($db_database);
$get_query = "SELECT * FROM `".$table."` WHERE `".$table."` = '".$id."' LIMIT 1";
$get_result = mysql_query($get_query, $db);
$get_row = mysql_fetch_array($get_result);
if($get_row){
$search = "`members`.`".$table.'_id` = '.$get_row['id'];
$query = "SELECT members.*, country.id, country.country AS country, state.id, state.state AS state, city.id, city.city AS city FROM (members JOIN country ON members.country_id = country.id JOIN state ON members.state_id = state.id JOIN city ON members.city_id = city.id) LEFT JOIN region ON members.region_id = region.id WHERE ".$search." ORDER BY country.country ASC, state.state ASC, city.city ASC, members.l_name ASC";
$result = mysql_query($query, $db) or die(mysql_error());
$row = mysql_fetch_array($result);
$printed_states = array();
$printed_cities = array();
do{
if($row['approved'] and $row['web'] and $row['expiration_date'] > date("Y-m-d") ){
if($row['web']){
if( !in_array($row['state'], $printed_states) ){
$string .= '
'.$row['state'].'
';
$printed_states[] = $row['state'];
}
if( !in_array($row['city'], $printed_cities) ){
$string .= ''.$row['city'].'
';
$printed_cities[] = $row['city'];
}
$string .= '
'.$row['business'].' |
Skills: | '.$row['skills'].' |
Location: | '.$row['city'].', '.$row['state'].' |
|
|
';
} else {
}
}
} while($row = mysql_fetch_array($result));
return $string;
} else return "Your search returned no results.";
}