Now I get..
Code: Select all
No images available!Code: Select all
<?php
#########################################
# Admin Gallery System #
# gallery.php #
#########################################
include("gallery/functions_main.inc.php");
include("gallery/fields_login.inc.php");
include("gallery/gallery.css");
$table = "art";
$max_results = 8;
// if there's page number, use it
// if not, set one
if(!isset($_GET['page'])) {
$n = 1;
} else {
$n = $_GET['page'];
}
// Figure out the limit for the query based
//on the current page number.
$from = (($n * $max_results) - $max_results);
// connect to db and limiting it to $max_results
Connect_to_db("Vars.inc.php");
$sql = "SELECT * FROM $table ORDER BY date DESC LIMIT $from, $max_results";
$result = mysql_query($sql);
if (!$result) {
echo("<P>Error performing query: " .
mysql_error() . "</P>");
exit();
}
?>
<p class="style3" align="left">Art Gallery</p>
<p align="center"><span class="style7"><strong>Notice: </strong></span>Clicking on a picture will open in a new window!</p>
<?php
// checks if there is available data in the database.
if ( mysql_num_rows($result) == 0 ) {
echo "<h2><center><font color='red'>No images available!</font></h2></center>"; }
else { ?>
<table border="0" align="center" cellpadding="5" cellspacing="5" width="80%">
<?php
// loops with remainder for table column calucation.
$x = 0;
while ( $row = mysql_fetch_array($result) ) {
if ($x % 4 == '0') { echo "<tr align='center'>"; }
?>
<td align="center" class="gallerytb">
<span class="style1"><?php echo("<a href='gallery/view.php?pix=" .$row["name"] . "' target='_new'><img border='0' src='" . $row["tbimage"] . "' alt='" . $row["title"] . "'></a><br><br><div class='titlebg'><b>" . $row['title'] . "</b></div>");
$x = $x + 1; ?></span> </td>
<?php
}
?>
</tr></table>
<?php } ?>
<br>
<?php
echo "<center>";
// Figure out the total number of results in DB:
$total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM $table"),0);
// Figure out the total number of pages.
$total_pages = ceil($total_results / $max_results);
// Build Previous Link
if($n > 1) {
$prev = ($n - 1);
echo "<a href='" . $_SERVER['PHP_SELF'] ."?page=gallery&n=$prev'><<Previous</a>";
}
for($i = 1; $i <= $total_pages; $i++) {
if (($n) == $i) {
echo "$i ";
} else {
echo "<a href='". $_SERVER['PHP_SELF'] ."?page=gallery&n=$i'>$i</a> ";
}
}
// Build Next Link
if ($n < $total_pages) {
$next = ($n + 1);
echo "<a href='". $_SERVER['PHP_SELF'] ."?page=gallery&n=$next'>NEXT>></a>";
}
echo "</center>";
mysql_close();
?>
<span align="center"><?php echo $page['bottom']; ?>