|
Museum Search Results |
|
To change the sort order of the results (by Museum Name, City, Country, etc.), click on the underlined column heading.
For more information about each museum, click the Details button.
Comments, suggestions, issues or additions please send an email to
.
|
|
include("dbinfo.inc.php");
// replace this with the path to the HTML Purifier library
require_once '/var/www/vhosts/research.famsi.org/httpdocs/htmlPure440/library/HTMLPurifier.auto.php';
$config = HTMLPurifier_Config::createDefault();
// configuration goes here:
$config->set('Core.Encoding', 'ISO-8859-1'); // replace with your encoding
$config->set('HTML.Doctype', 'HTML 4.01 Transitional'); // replace with your doctype
$purifier = new HTMLPurifier($config);
//$clean_html = $purifier->purify($dirty_html);
##include database info and connect to database
$db=mysql_connect(localhost,$username,$password);
@mysql_select_db($database,$db) or die( "Unable to select database");
mysql_set_charset('utf8', $db);
mysql_query("set names utf8");
$search="";
$order="";
$where="";
##if search word does not exist retrieve it from search page else use the one passed in URL
$name=$purifier->purify($_GET['name']);
$city=$purifier->purify($_GET['city']);
$state=$purifier->purify($_GET['state']);
$country=$purifier->purify($_GET['country']);
$focus=$purifier->purify($_GET['focus']);
if(!$name && !$city && !$state && !$country && !$focus) {
$search = "";
}
if($name) {
if($where == "") {
$where="where name like '%$name%'";
$search = "name=$name";
} else {
$where = " and name like '%$name%'";
}
}//end if $name
if($city) {
if($where == "") {
$where="where city like '%$city%'";
$search = "city=$city";
} else {
$where = " and city like '%$city%'";
}
}//end if $city
if($state) {
if($where == "") {
$where="where state like '%$state%'";
$search = "state=$state";
} else {
$where = " and state like '%$state%'";
}
}//end if $state
if($country) {
if($where == "") {
$where="where country like '%$country%'";
$search = "country=$country";
} else {
$where = " and country like '%$country%'";
}
}//end if $country
if($focus) {
if($where == "") {
$where="where focus like '%$focus%'";
$search = "focus=$focus";
} else {
$where = " and focus like '%$focus%'";
}
}//end if $focus
//set sort order by columns
$sortDefault = 'name';
$allowedSort = array ('name', 'city', 'state', 'country', 'website');
//check if sort order is set, if not set default
if(!isset($_GET['order']) || !in_array ($_GET['order'], $allowedSort)) {
$order = $sortDefault;
} else {
$order = $_GET['order'];
}
// Define your colors for the alternating rows
$color1 = "#FBF2D5";
$color2 = "#FEFEE4";
$row_count = 0;
$result = mysql_query("select * from museum_list $where order by $order");
$result2 = mysql_query("select * from museum_list $where order by $order");
$sql="select * from museum_list $where order by $order";
//echo $sql;
$result_cnt = mysql_num_rows($result2);
$record_cnt = mysql_num_rows($result);
if($record_cnt == 0) {
echo '';
echo '';
echo 'No data to display';
echo ' | ';
//exit;
}
echo '';
echo 'Results 1 - ' . $record_cnt . ' of '. $record_cnt .' | ';
echo '';
echo '';
echo ' | ';
echo 'Name | ';
echo 'City | ';
echo 'State | ';
echo 'Country | ';
//echo 'Website |
echo ' ';
for ($i=0; $i<$record_cnt; $i++) {
$row = mysql_fetch_array($result);
$row_color = ($row_count % 2) ? $color1 : $color2;
echo '';
echo ' | ';
echo '';
if($row['name']) {
echo $row['name'];
} else {
echo ' ';
}
echo ' | ';
echo '';
if ($row['city']) {
echo $row['city'];
} else {
echo ' ';
}
echo ' | ';
echo '';
if ($row['state']) {
echo $row['state'];
} else {
echo ' ';
}
echo ' | ';
echo '';
if ($row['country']) {
echo $row['country'];
} else {
echo ' ';
}
echo ' | ';
/*
echo '';
if ($row['website']) {
echo $row['website'];
} else {
echo ' ';
}
echo ' |
*/
echo ' ';
// Add 1 to the row count
$row_count++;
}
echo ' | ';
echo '';
echo 'Results 1 - ' . $record_cnt . ' of '. $record_cnt .' | ';
?>
|
|