coolphpdude Posted March 26, 2009 Share Posted March 26, 2009 Hi guys, I am outputting pictures into a gallery page using a while loop. // thumbnail table echo "<table width='100%' border='0' cellspacing='0' cellpadding='10'>"; //set number of columns and initial column number $numcols = 3; // how many columns to display $numcolsprinted = 0; // no of columns so far // get the results to be displayed $query = "SELECT * FROM pics WHERE pic_id='$id'"; $mysql_result = mysql_query($query) or die (mysql_error()); // get each row while($myrow = mysql_fetch_array($mysql_result)) { //get data $pic = $myrow[0]; if ($numcolsprinted == $numcols) { print "</tr>\n<tr height ='500'>\n"; $numcolsprinted = 0; } $pic_name = $myrow["vp_thumb"]; $pic_id = $myrow["vp_id"]; // output row from database echo "<td width='300' height='500' align='center' valign='top'><img src='$pic_name' border='0'></td>\n"; // bump up row counter $numcolsprinted++; } // end while loop $colstobalance = $numcols - $numcolsprinted; for ($i=1; $i<=$colstobalance; $i++) { } print "<TD height ='500'></TD>"; echo"</table>"; The while loop works great. it outputs all of my thumbnails into a 3 column table. the problem i am having is when it outputs the next row of pictures. The next row is actually directly under the first row (i.e not a single pixel between the picture in the first row and the second row. Any idea's why it is doing this?? as you can see i've tried adding height='500' to both the <td> tags and the <tr> tag>. Cheers Quote Link to comment Share on other sites More sharing options...
unska Posted March 26, 2009 Share Posted March 26, 2009 Have you tried using cellspacing or cellpadding on HTML? Quote Link to comment Share on other sites More sharing options...
coolphpdude Posted March 26, 2009 Author Share Posted March 26, 2009 i've got the cell padding which you see within <table> tag. Im a little confused with this because i am sure the html should produce spacing with the settings i have above. I may have put this loop together wrong which is creating the problem but i cant seem to spot where i am going wrong! Quote Link to comment Share on other sites More sharing options...
vicodin Posted March 26, 2009 Share Posted March 26, 2009 You cant set the height of <tr> you need to set the height of <td>. Also Cell padding is the amount of padding between the cell inside wall and what ever is in it and cell spacing is the amount of spacing between cells. Quote Link to comment Share on other sites More sharing options...
coolphpdude Posted March 26, 2009 Author Share Posted March 26, 2009 yeah i know, i just put that in to see if it would have any effect... but it didnt. Ive also just tried removing the valign as it was setting the image to appear at the top but that also didnt change anything. Quote Link to comment Share on other sites More sharing options...
coolphpdude Posted March 26, 2009 Author Share Posted March 26, 2009 please visit http://www.quatresaisonsvilla.com/gallery.php to see my problem! its driving me nuts!!! Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted March 26, 2009 Share Posted March 26, 2009 cell padding/spacing should only be set within the opening table tag. You cannot set cell padding/spacing within the TD tags. To space table rows out you should set cellspacing, eg echo "<table width='100%' border='0' cellspacing='10' cellpadding='0'>"; Quote Link to comment Share on other sites More sharing options...
coolphpdude Posted March 26, 2009 Author Share Posted March 26, 2009 your a genius and i love you!!! cheers, i knew i was missing something. Thanks for your help, works a treat!! 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.