<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Distributors and Publishers of Contemporary Arts</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<center>
<table id="tableAll" cellpadding="0" cellspacing="0">
<tr><td valign="top">
<table width="100%" cellpadding="0" cellspacing="0">
<tr><td>
<img src="top_ban.jpg">
</td></tr>
</table>
<table id="search" width="100%" cellpadding="0" cellspacing="0">
<tr>
<td id="main" valign="top">
<?php
function paginate($limit=2) {
global $admin;
$sql = "SELECT FOUND_ROWS();";
$result = mysql_query($sql)
or die(mysql_error());
$row = mysql_fetch_array($result);
$numrows = $row[0];
$pagelinks = "<div class=\"pagelinks\">";
if ($numrows > $limit) {
if(isset($GET['page'])){
$page = $GET['page'];
} else {
$page = 1;
}
$currpage = $SERVER['PHP_SELF'] . "?" . $SERVER['QUERY_STRING'];
$currpage = str_replace("&page=".$page,"",$currpage);
if($page == 1){
$pagelinks .= "<span class=\"pageprevdead\">< PREV</span>";
}else{
$pageprev = $page - 1;
$pagelinks .= "<a class=\"pageprevlink\" href=\"" . $currpage .
"&page=" . $pageprev . "\">< PREV</a>";
}
$numofpages = ceil($numrows / $limit);
$range = $admin['pageRange']['value'];
if ($range == "" or $range == 0) $range = 7;
$lrange = max(1,$page-(($range-1)/2));
$rrange = min($numofpages,$page+(($range-1)/2));
if (($rrange - $lrange) < ($range - 1)) {
if ($lrange == 1) {
$rrange = min($lrange + ($range-1), $numofpages);
} else {
$lrange = max($rrange - ($range-1), 0);
}
}
if ($lrange > 1) {
$pagelinks .= "..";
} else {
$pagelinks .= " ";
}
for($i = 1; $i <= $numofpages; $i++){
if ($i == $page) {
$pagelinks .= "<span class=\"pagenumdead\">$i</span>";
} else {
if ($lrange <= $i and $i <= $rrange) {
$pagelinks .= "<a class=\"pagenumlink\" " .
"href=\"" . $currpage . "&page=" . $i .
"\">" . $i . "</a>";
}
}
}
if ($rrange < $numofpages) {
$pagelinks .= "..";
} else {
$pagelinks .= " ";
}
if(($numrows - ($limit * $page)) > 0){
$pagenext = $page + 1;
$pagelinks .= "<a class=\"pagenextlink\" href=\"" . $currpage .
"&page=" . $pagenext . "\">NEXT ></a>";
} else {
$pagelinks .= "<span class=\"pagenextdead\">NEXT ></span>";
}
} else {
$pagelinks .= "<span class=\"pageprevdead\">< " .
"PREV</span> ";
$pagelinks .= "<span class=\"pagenextdead\"> " .
"NEXT ></span> ";
}
$pagelinks .= "</div>";
return $pagelinks;
}
global $limit;
if (isset($_GET['page'])) {
$page = $_GET['page'];
} else {
$page = 1;
}
if ($limit == "") $limit = 2;
$start = ($page - 1) * $limit;
include "linkdb.php";
$query = "select SQL_CALC_FOUND_ROWS " . "* from item,category,artist,style where item_artist = artist_id AND item_category = category_id AND item_style = style_id " .
"LIMIT $start,$limit";
// category selector
if($_POST['artist'] != "all") {
$query = $query . " AND artist_name = '" . $_POST['artist']."'";
}
// category selector
if($_POST['category'] != "all") {
$query = $query . " AND category_name = '" . $_POST['category']."'";
}
// style selector
if($_POST['style'] != "all") {
$query = $query . " AND style_name = '" . $_POST['style']."'";
}
// price bracket selector
if($_POST['price1'] == "upto100") $query = $query . " AND item_price1 <= 100 ";
if($_POST['price1'] == "100-500") $query = $query . " AND (item_price1 >= 50000 and item_price1 <=500 )";
if($_POST['price1'] == "500-1000") $query = $query . " AND (item_price1 >= 80000 and item_price1 <=1000 )";
if($_POST['price1'] == "over1000") $query = $query . " AND item_price1 >= 1000 ";
$result = mysql_query($query,$link) or die(mysql_error());
$pagelinks = paginate($limit);
$num_movies = mysql_num_rows($result);
?>
<div id="mainContent2">
<br>
<br>
<?php
$header =<<<EOD
<table id="results" width="95%" cellpadding="2" cellspacing="1" align="center" border="0">
EOD;
if ($num_movies >= 1 ) {
$headers =<<<EOD
<tr>
<th>Item</th>
<th>Name</th>
<th>Artist</th>
<th>Category</th>
<th>Style</th>
<th>Prices from</th>
</tr>
EOD;
}
$color = "#ffffff";
while ($rows=mysql_fetch_assoc($result)) {
if ($color == "#ffffff") {
$color = "#eeeeee";
}
else {
$color = "#ffffff";
}
$image1Var = $rows['item_image1'];
$idVarPic = $rows['item_id'];
if ($image1Var == '')
{
$idVarNoPic = 'noImage';
}
else {
$idVarNoPic = $rows['item_id'];
}
$nameVar = $rows['item_name'];
$artistVar = $rows['artist_name'];
$categoryVar = $rows['category_name'];
$styleVar = $rows['style_name'];
$priceVar = $rows['item_price1'];
$middle .=<<<EOD
<tr>
<td bgcolor="$color"><a href="itemDetails.php?item_id=$idVarPic"><img src="images/thumbs/$idVarNoPic.jpg"></a></td>
<td bgcolor="$color">$nameVar</td>
<td bgcolor="$color">$artistVar</td>
<td bgcolor="$color">$categoryVar</td>
<td bgcolor="$color">$styleVar</td>
<td bgcolor="$color">£$priceVar</td>
</tr>
EOD;
}
$movie_footer ="</table>";
print $header;
print $headers;
print $middle;
print $movie_footer;
?>
<h2>We found <?php echo $num_movies;?> items that matched your search criteria!</h2>
</div>
</td>
</tr>
</table>
</td></tr>
</table>
</center>
</body>
</html>