Jump to content

[SOLVED] adjusting cell or row height in a table within php while loop


coolphpdude

Recommended Posts

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

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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'>";

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.