Page 1 of 1

Displaying sql returns in a Table?

Posted: Thu Aug 25, 2005 11:57 am
by hward
I am trying to get my returns to display an image in a table with the name below it in a cell and have them side by side instead of below each other, This is the code I have that displays the image name and name side by side but I can't figure out how to get it to do it in a table.

Code: Select all

while($row = mysql_fetch_array($result)) 


{ 
   echo $row[image].'--'.$row['name'].'  ';
	
  } 
echo '<br>'; 
echo '<br>';
echo '<br>';
I was wondering if you could just return something like this

Code: Select all

<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="17%" height="171">
  <tr>
    <td width="100%" height="132">
    <p align="center">
    <img border="0" src="image.jpg" width="172" height="175"></td>
  </tr>
  <tr>
    <td width="100%" height="38">
    <p align="center">Name</td>
  </tr>
</table>

Posted: Thu Aug 25, 2005 12:24 pm
by Stewsburntmonkey
That should work as a template. However the <td> tag can take the align attribute (or better yet use style/css) so there is no need for the <p> tags. :)

Posted: Thu Aug 25, 2005 12:49 pm
by hward
this gets me close but just puts the name on the right of the image

Code: Select all

while($row = mysql_fetch_array($result)) 


{ 
  // echo $row['stock_num'].'--'.$row['gender'].'&nbsp;&nbsp;';
  echo "
    <td width='130' height='132'>
    <align='center'>
    <img border='0' src='1.jpg' width='130' height='132'></td>
  </tr>
  <tr>
    <td width='170' height='38'>
    <align='center'>Name</td>
  </tr>
";
	
  }

Posted: Thu Aug 25, 2005 12:53 pm
by Stewsburntmonkey
You forgot the opening <tr> tag. Also <td align="center"> will work, its deprecated, but less so than the <align> tag. :)