Next Button: PHP and mysql

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Adelyra
Forum Newbie
Posts: 3
Joined: Wed Sep 22, 2010 2:56 pm

Next Button: PHP and mysql

Post by Adelyra »

Hello everyone!

I'm working on a Next and Previous button ad I'm trying to figure out the logic...

This is what I was thinking however it only brings up the last item in the table:

Code: Select all

if(isset($_POST['btnNext_x'])){

	$numRowSel = mysql_query("SELECT * FROM gallery WHERE Category = 'Weddings'");
	$numRow = mysql_num_rows($numRowSel);
	
	//$contentPic = $numRow;
                //This returns 36 (the proper number)

	for($i = 1; $i <= $numRow; $i++){
		
		$strSQLFile = mysql_query("SELECT * FROM gallery WHERE Category = 'Weddings' LIMIT " . $i . ", 1");
		$rowFile = mysql_fetch_array($strSQLFile);
		$FileNext = $rowFile['Filename'];
		
		$contentPic = "<img src='../dashboard/imgs/" . $FileNext . "' alt='contentPic'/>";

                                //DEBUG
                                //$contentPic = $i;
	
	}
}
In point form, I'll explain what I've done:

-Check to see if button is clicked
-Select everything from table with category 'Weddings'
-Check the row count of the data returned (36)
-For statement starting at 1, stopping if equal to number of rows, increasing by 1
-Get everything from table with category 'Weddings' limiting to counter number and only one record (I've tested this inpypmyadmin and it works)
-Get column 'Filename'
-Insert Filename into a image tag and echo in content below via php variable.

So, in my head I should think this would work but it doesn't. The FileNext variable comes back empty.
I also tried just to echo the $i counter (ex: $contentPic = $i;) and it always returns 36 even if I press the button.

I'm open to different ways of doing this so don't be affraid to suggest.
Thanks!
Post Reply