Next Button: PHP and mysql
Posted: Wed Sep 22, 2010 3:08 pm
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:
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!
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;
}
}-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!