Danian Posted July 17, 2008 Share Posted July 17, 2008 Hi All, I am trying to grab data froma a MySQL database and display it Horizontally. I can get the data from the table OK, and display it horizontally but i can not get it display on more then one row. I would like it to drop down a row after every 4 images i.e. 4 4 4 4 4 4 4 4 4 4 4 4 I found a piece of code online, but could not get it to work. I would be greatful if someone could help. Please see some of the code used: <table border="0" valign="top"> <tr> <?php while ($row = mysql_fetch_array($result)) { $imageID = $row['imageID']; $image = $row['image']; $imageInfo = $row['imageInfo']; $gallery_memberID = $row['gallery_memberID']; $name = $row['Name']; for( $i = 1 ; $i <= sizeof($row) ; ++$i ) $gallery_image_sql = "SELECT gallery_members.*, members.Name, members.squad FROM gallery_members INNER JOIN members ON gallery_memberID = MemberID WHERE gallery_imageID = $imageID"; $gallery_image_result=mysql_query($gallery_image_sql, $link); ?> <td> <table width="155" border="0" cellspacing="0" cellpadding="0" class="gallery"> <tr> <td width="15"></td> <td width="125" height="10" align="center"></td> <td width="15"></td> </tr><tr> <td width="15"></td> <td width="125" align="center"> <?php if($image!=""){ echo "<a href=\"gallery_display.php?imageID=$imageID\"><img src=\"$image\" width=\"125\" height=\"125\"></a>"; } ?> </td> <td width="15"></td> </tr><tr> <td width="15"></td> <td width="125" height="10" align="center"></td> <td width="15"></td> </tr><tr> <td width="15"></td> <td width="125" align="center"><?php echo $imageInfo;?></td> <td width="15"></td> </tr><tr> <td width="15"></td> <td width="125" height="10" align="center"></td> <td width="15"></td> </tr><tr> <td width="15"></td> <td width="125" align="center"> <?php while ($gallery_image_row = mysql_fetch_array($gallery_image_result)) { $gallery_memberID = $gallery_image_row['gallery_memberID']; $Name = $gallery_image_row['Name']; echo "<a href=\"squad_details.php?memberid=$gallery_memberID\">$Name</a>"; echo " "; } ?></td> <td width="15"></td> </tr> <?php if($curr_usertype==USR_TYP_ADMIN){ ?> <tr> <td width="15"></td> <td width="125" height="10" align="center"></td> <td width="15"></td> </tr><tr> <td width="15"></td> <td width="125" align="center"><?php echo "<a href=\"gallery_edit.php?imageID=$imageID\">Edit</a>"; echo " | "; echo "<a href=\"#\" onclick=\"deleteItem('Image', 'gallery_delete_proc.php?imageID=', '$imageID');return false;\">Delete</a>"; ?> </td> <td width="15"></td> </tr> <?php } ?> </table> </td> <?php if ($i%4==0) { echo "</tr>\n<tr>\n"; } } ?> </tr> </table> You can view the page at: http://testing.charltonrangers.co.uk/gallery.php Thanks in advance, Danian (edited by kenrbnsn to change the tags to tags) Link to comment https://forums.phpfreaks.com/topic/115186-horizontal-loop/ Share on other sites More sharing options...
kenrbnsn Posted July 17, 2008 Share Posted July 17, 2008 Take a look at the solution I provided in another similar thread a few days ago. Ken Link to comment https://forums.phpfreaks.com/topic/115186-horizontal-loop/#findComment-592359 Share on other sites More sharing options...
Danian Posted July 17, 2008 Author Share Posted July 17, 2008 Take a look at the solution I provided in another similar thread a few days ago. Ken Ken, Many thanks for that. The problem i am having is that you code is way over my head. I have only been using PHP for a short while and get lost at what is going on. Anyway you could break it down for me? Thanks in advance, Danian Link to comment https://forums.phpfreaks.com/topic/115186-horizontal-loop/#findComment-592450 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.