Location: PHPKode > projects > Kwalbum > kwalbum/new_pics.php
<?php

/**
 * Display a table with thumbnails of the newest pictures.
 *
 * @version 2.1.4
 * @since 2.0
 * @author Tim Redmond <hide@address.com>
 * @package kwalbum
 */

require_once pathinfo(__FILE__, PATHINFO_DIRNAME).'/include/DBConnection.php';
require_once pathinfo(__FILE__, PATHINFO_DIRNAME).'/include/funcGetImageCode.php';

if (!isset ($DB))
	$DB = new DBConnection();

$numRows = (isset ($_GET['r']) ? (int) $_GET['r'] : 0);
if (!$numRows)
	$numRows = 1;
$numCols = (isset ($_GET['c']) ? (int) $_GET['c'] : 0);
if (!$numCols)
	$numCols = 1;
$numPics = $numRows * $numCols;

$query = 'SELECT ItemId, ItemPath, ItemFilename, ItemTypeId FROM ' . ITEM_TABLE .
" WHERE ".USER_CAN_VIEW_QUERY.
" ORDER BY ItemId DESC" .
" LIMIT $numPics";
$result = $DB->query($query);

if ($result->num_rows < $numPics)
{
	$numPics = $result->num_rows;
}
if ($numPics > 0)
{
	$c = 0;
	$r = 0;
?>

<div id="newPics">
<?
do
{
	if (0 == $c)
		echo '<div>';
	if ($row = $result->fetch_array(MYSQLI_ASSOC))
	{
		echo "<a href='".PAGE_URL."i=$row[ItemId]'>".GetImageCode($row['ItemPath'], $row['ItemFilename'], $row['ItemTypeId'], $row['ItemId'])
		."</a>\n";
	}
	$c++;
    if ($numCols == $c)
    {
    	echo "</div>\n";
    	if (!$row)
    		break;
    	$r++;
    	$c = 0;
    }
} while($r < $numRows);
echo '</div>';

} else
	echo 'No New Pictures';
?>
Return current item: Kwalbum