conan318 Posted October 31, 2011 Share Posted October 31, 2011 Ok the pagination part is all working fine. but i thought id be able to create a heap variables inside the loop then display the images in a table. the only trouble is all variables are grabbing the same img. i need them to grab the 10 different records. thanks $sql = "SELECT * FROM mongrels_db.gallery ORDER BY id DESC LIMIT $offset, $rowsperpage "; $result = mysql_query($sql, $conn) or trigger_error("SQL", E_USER_ERROR); // while there are rows to be fetched... while ($list = mysql_fetch_array($result)) { $img1=$list['img']; $img2=$list['img']; $img3=$list['img']; $img4=$list['img']; $img5=$list['img']; $img6=$list['img']; $img7=$list['img']; $img8=$list['img']; $img9=$list['img']; $img10=$list['img']; // echo data } // end while echo "<table><tr>"; echo "<td>"."<img src='../gallery/".$img1 ."' width='100' height='100''> "."</td>"; echo "<td>"."<img src='../gallery/".$img2 ."' width='100' height='100''> "."</td>"; echo "<td>"."<img src='../gallery/".$img3 ."' width='100' height='100''> "."</td>"; echo "<td>"."<img src='../gallery/".$img4 ."' width='100' height='100''> "."</td></tr>"; echo "<tr><td>"."<img src='../gallery/".$img5 ."' width='100' height='100''> "."</td>"; echo "<td>"."<img src='../gallery/".$img6 ."' width='100' height='100''> "."</td>"; echo "<td>"."<img src='../gallery/".$img7 ."' width='100' height='100''> "."</td>"; echo "<td>"."<img src='../gallery/".$img8 ."' width='100' height='100''> "."</td>"; echo "<tr><td>"."<img src='../gallery/".$img9 ."' width='100' height='100''> "."</td>"; echo "<td>"."<img src='../gallery/".$img10 ."' width='100' height='100''> "."</td></tr>"; Quote Link to comment Share on other sites More sharing options...
MasterACE14 Posted October 31, 2011 Share Posted October 31, 2011 that's defeating the purpose of the loop. Do this instead: $sql = "SELECT * FROM mongrels_db.gallery ORDER BY id DESC LIMIT $offset, $rowsperpage "; $result = mysql_query($sql, $conn) or trigger_error("SQL", E_USER_ERROR); echo "<table><tr>"; // while there are rows to be fetched... while ($list = mysql_fetch_array($result)) { echo "<td>"."<img src='../gallery/".$list['img'] ."' width='100' height='100''> "."</td>"; } // end while Quote Link to comment Share on other sites More sharing options...
QuickOldCar Posted October 31, 2011 Share Posted October 31, 2011 $sql = "SELECT * FROM mongrels_db.gallery ORDER BY id DESC LIMIT $offset, $rowsperpage "; $result = mysql_query($sql, $conn) or trigger_error("SQL", E_USER_ERROR); echo "<table><tr>"; // while there are rows to be fetched... while ($list = mysql_fetch_array($result)) { $img=$list['img']; // echo data echo "<td>"."<img src='../gallery/".$img."' width='100' height='100''> "."</td>"; } // end while echo "</tr><table>"; otherwise to display the data later would have to make them an array masterace beat me, we were close Quote Link to comment Share on other sites More sharing options...
conan318 Posted October 31, 2011 Author Share Posted October 31, 2011 i did do it like that to start with. but could not work how to display 4 img then create a new table row inside the loop im sure there is a way to do it. Quote Link to comment Share on other sites More sharing options...
QuickOldCar Posted October 31, 2011 Share Posted October 31, 2011 use css styles to make the tables the way you want Quote Link to comment Share on other sites More sharing options...
conan318 Posted October 31, 2011 Author Share Posted October 31, 2011 use css styles to make the tables the way you want Can you give me an example of this or point me to tutorial ? Quote Link to comment Share on other sites More sharing options...
QuickOldCar Posted November 1, 2011 Share Posted November 1, 2011 http://dustinbrewer.com/creating-a-photo-gallery-in-css-without-tables/ http://www.web3mantra.com/2011/03/28/25-css-image-galleries/ http://coding.smashingmagazine.com/2007/05/18/30-best-solutions-for-image-galleries-slideshows-lightboxes/ http://www.cssplay.co.uk/menu/content100.html http://www.cssplay.co.uk/menu/slide_show.html Just to show a few Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.