aadil Posted January 19, 2012 Share Posted January 19, 2012 I want to display 3 clickable images in a single row which repeats as long as there is data in the database, so far it is displaying a single clickable image from the database. below is all the code.. <table width="362" border="0"> <?php $sql=mysql_query("select * from `publication` GROUP BY `catsue`") or die(mysql_error()); $num=mysql_num_rows($sql); while($rowfor=mysql_fetch_array($sql)) { $cat=$rowfor['catsue']; $pic=mysql_query("select * from `category` where `catsue`='$cat'") or die(mysql_error()); $picP=mysql_fetch_array($pic); $base=basename($picP['title']); ?> <tr> <td width="352" height="88"><table width="408" border="0"> <tr> <td width="113" rowspan="5"><a href="archive_detail.php?id=<?php echo $rowfor['id'];?>&category=<?php echo $rowfor['catsue'];?>"><img src="ad/pic/<?php echo $base;?>" width="100" height="100" border="0"/></a></td> <td width="94">Title</td> <td width="179" height="1"><?php echo $rowfor['catsue'];?> </td> </tr> <tr> <td> </td> <td width="179" height="3"> </td> </tr> <tr> <td> </td> <td width="179" height="8"> </td> </tr> <tr> <td> </td> <td width="179" height="17"> </td> </tr> <tr> <td> </td> <td width="179" height="36"> </td> </tr> </table></td> </tr> <?php }?> </table> Quote Link to comment https://forums.phpfreaks.com/topic/255327-how-to-display-3-clickable-images-in-a-row-from-database/ Share on other sites More sharing options...
joel24 Posted January 19, 2012 Share Posted January 19, 2012 you need another while loop for the second mysql query, at the moment you're only retrieving the first image returned from the query. Quote Link to comment https://forums.phpfreaks.com/topic/255327-how-to-display-3-clickable-images-in-a-row-from-database/#findComment-1309094 Share on other sites More sharing options...
El Chupacodra Posted January 19, 2012 Share Posted January 19, 2012 Are you always going to display only three or do you mean an unknown number of pictures in a three column layout? If it's the last one you need a counter for how many pictures you already displayed plus a last line to be padded if you run out of pictures. Quote Link to comment https://forums.phpfreaks.com/topic/255327-how-to-display-3-clickable-images-in-a-row-from-database/#findComment-1309127 Share on other sites More sharing options...
aadil Posted January 19, 2012 Author Share Posted January 19, 2012 Yes I want to display unknown numberof pictures in a 3 column layout...Can i get some coding for it Quote Link to comment https://forums.phpfreaks.com/topic/255327-how-to-display-3-clickable-images-in-a-row-from-database/#findComment-1309146 Share on other sites More sharing options...
joel24 Posted January 19, 2012 Share Posted January 19, 2012 while ($picP=mysql_fetch_array($pic)) { $base=basename($picP['title']); #... code to iterate between images goes here, # you'll need a counter and when that reaches 3 or modulus 3 == 0, then echo a new table row } Quote Link to comment https://forums.phpfreaks.com/topic/255327-how-to-display-3-clickable-images-in-a-row-from-database/#findComment-1309175 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.