Save the below code as
view_all.php and put it in the root directory with your other phpKImageHost files.
Demo
http://www.maxogc.com/image_hosting/view_all.phpCODE
<?php
include "header.php";
if ($_GET['page'])
{
$limit = $_GET['page'] * 20 - 20;
$limit = "LIMIT " . $limit . ",20";
$page=$_GET['page'];
}
else
{
$limit = "LIMIT 20";
$page = 1;
}
//Lets try connecting to mySQL
@ $db = mysql_pconnect($mysql['host'], $mysql['user'], $mysql['pass']);
//IT"S NOT WORKING!
if (!$db)
{
die("error");
}
mysql_select_db($mysql['db']);
//Lets see what images we have...
$query = "SELECT * FROM images";
//Suspense is killing me. Lets see.
$pagesquery = mysql_query($query);
$num_rows = mysql_num_rows($pagesquery);
if(intval($num_rows / 20) != ($num_rows / 20))
{
$totalpages = intval($num_rows / 20) + 1;
}
else
{
$totalpages = $num_rows / 20;
}
echo "<br><b>Page:</b><br>";
//Dunno how to make the page list without it being inefficient...Oh well, this works...for now.
if($page > 1)
{
echo ' <a href="view_all.php?page=' . ($page-1) . '">Previous</a> ';
}
echo ' <a href="view_all.php?page=1">1</a> ';
if ($totalpages>1)
{
echo '<a href="view_all.php?page=2">2</a> ';
}
if ($totalpages>3)
{
if($totalpages>4)
{
if($page >3)
{
echo '... ';
}
if($page > 3 and $page < $totalpages)
{
echo '<a href="view_all.php?page=' . ($page-1) . '">' . ($page-1) . '</a> ';
}
if($page < $totalpages-1 and $page > 2)
{
echo $page . ' ';
}
if($page > 1 and $page < $totalpages-2)
{
echo '<a href="view_all.php?page=' . ($page+1) . '">' . ($page+1) . '</a> ';
}
if($page<$totalpages-2)
{
echo '... ';
}
}
echo '<a href="view_all.php?page=' . ($totalpages-1) . '">' . ($totalpages-1) . '</a> ';
}
if ($totalpages>2)
{
echo '<a href="view_all.php?page=' . $totalpages . '">' . $totalpages . '</a> ';
}
if($page != $totalpages)
{
echo ' <a href="view_all.php?page=' . ($page+1) . '">Next</a> ';
}
echo "<br><br><br>";
//That was a lot of code for a seemingly simple thing.
//Lets see what images we have...
$query = "SELECT * FROM images ORDER BY `id` ASC " . $limit;
//Suspense is killing me. Lets see.
$result = mysql_query($query);
$num_results = mysql_num_rows($result);
if($num_results == 0)
{
echo "<font class='extra'><br><br><br>No results<br><br><br></font>";
}
if(intval($num_results/4) == ($num_results/4))
{
$tablerows = $num_results/4;
}
else
{
$tablerows = intval($num_results/4) + 1;
}
echo "<table>";
for ($i = 0; $i < $tablerows; $i++)
{
echo "<tr>";
for($c = 0; $c < 4; $c++)
{
echo "<td>";
$row = mysql_fetch_array($result);
if(!$row)
{
break;
}
$id = $row['id'];
echo '<div id="' . $id . '"><a href="view/' . $id . '"><img src="uploads/thumb_' . $id . '" border="1"></a> <br>';
$comments = $row['comments'];
echo '<font class="txt"><b>Comments:</b><br>';
echo (stripslashes($comments));
$size = round($row['size']/1024);
$views = $english_format_number = number_format($row['downloads']);
echo '<br><b>Original size:</b> '. $size .' KB<br><b>Viewed:</b> '. $views .' times</font><br>';
echo "</td>";
}
echo "</tr>";
}
echo "</table>";
include "footer.php";
die();
include "footer.php";
?>
EDITNow includes the comments, thumbnail size and how many times the image was viewed.