Location: PHPKode > scripts > Image Page Turner > image-page-turner/pageturner.php3
<?php
    /*
	Author: Brady Owens  hide@address.com
	Distributed under GNU public liscense
	This piece of code reads from a MySQL database, or a database of
	your liking and displays images, where the information  for these
	images are contained within the database.
	It offeres a page turning style of display, one image at a time with
	navagational buttons at the bottom.
	You can modify this script however you like to fit your needs.	
	*/
		
	$db = mysql_connect("localhost","login","password"); 
	mysql_select_db("db_name",$db);
	if(!isset($imagepointer)){$imagepointer = 1;} //checking to see if $imagepointer has been initialized 
	if($imagepointer == 0){$imagepointer = 1;} //my database index started with 1 and not zero
	$sql = "select * from table_name where index = '$imagepointer'";
	$result = mysql_query($sql,$db);
	$row = mysql_fetch_array($result);
	
	//section finds out the max number of pictures
	$sql1 = "select * from table_name"; 
	$result1 = mysql_query($sql1,$db);
	$numrows = mysql_num_rows($result1);
	
	//section takes the data from the database and puts it into a variable
	$rownum	 = $row["num"]; 
	$author = $row["author"];
	$comment = $row["comment"];
	$filename = $row["filename"];
	  
	//Displaying the image and information along with it   	   
    echo "<center><img src=\"$filename\"></center><br><font color=\"#FFB903\">Author:</font>&nbsp $author<br><font color=\"#FFB903\">Comment:</font>&nbsp $comment ";
	
	echo "<div align='center'>"; //formating
	
	//This section contains the two navigational buttons.
	//The IF statements prevent the buttons being displayed
	//when the pointer is at the end or begining of the images.
	//If you have problems with this section remove the PHP_SELF
	//variable and replace it with the file name of this document.
	if($imagepointer != $numrows){
	echo "<FORM name='NEXT PIC' action='$PHP_SELF'><input type='hidden' name='imagepointer' value='";
	echo $imagepointer + 1;
	echo "'><input type='Submit' value='Next->'></form>";
	}
	
	if($imagepointer != 1){
	echo "<FORM name='NEXT PIC' action='$PHP_SELF'><input type='hidden' name='imagepointer' value='";
	echo $imagepointer - 1;
	echo "'><input type='Submit' value='<-Back'></form>";
	}
	echo "</div>";
	

?>
Return current item: Image Page Turner