All pastes #741913 Raw Edit

Miscellany

public php v1 · immutable
·published 2007-10-19 02:09 UTC
rendered paste body
<?phprequire_once('db.php');$limit = 7;$query_count = "SELECT count(*) FROM gallery";$result_count = mysql_query($query_count);$result_row = mysql_fetch_row($result_count);$totalrows = $result_row[0];/* What should result from this block of code is the newest illustration in the database being displayed if the illustration isn't specified in the url (e.g. "blah.php?illustration=got_oil" should result in gallery/got_oil/got_oil.jpg being displayed.)if(empty($illustration)) {	$max_id = max(mysql_fetch_array(mysql_query('SELECT id FROM gallery ORDER BY id DESC')));	$illustration = mysql_fetch_array(mysql_query('SELECT filename FROM gallery WHERE id="' . $max_id . '"'));	echo '<img src="gallery/' . $illustration['filename'] . '/' . $illustration['filename'] . '.jpg" /><br />';	}else {	echo '<img src="gallery/' . $illustration . '/' . $illustration . '.jpg" /><br />';	}*//* if(empty($page)) {	$page = 1;	}else {	$page = $_GET['page'];} */if (isset($_GET['page']) && is_numeric($_GET['page'])) {        $page = $_GET['page'];} else {        $page = 1;}$limitvalue = $page * $limit - ($limit);$query = "SELECT * FROM gallery ORDER BY id DESC LIMIT $limitvalue, $limit";$result = mysql_query($query) or die("Error: " . mysql_error());if($page != 1) {  		$pageprev = $page - 1;			 	echo '<a href="' . $_SERVER['PHP_SELF'] . '?&page=' . $pageprev . '">Previous</a> ';}else{	echo 'Previous'; }while($row = mysql_fetch_assoc($result)){ 	echo '<a href="' . $_SERVER['PHP_SELF'] . '?illustration=' . $row['filename'] . '"><img src="gallery/' . $row['filename'] . '/' . $row['filename'] . '-thumbnail.jpg" /></a>' . "\n";    }if(($totalrows - ($limit * $page)) > 0){	$pagenext = $page + 1;	echo '<a href="' . $_SERVER['PHP_SELF'] . '?&page=' . $pagenext . '">Next</a>';}else {	echo 'Next';}?>