Page 1 of 1

PHP and HTML table rows

Posted: Fri May 17, 2002 4:31 am
by knmwt15000
I have some data in a mysql database and want it displaying in a table so that each row of data is displayed in a cell. I know how to do this bit but does anyone know how I can get it to start a new row every 4 cells so I doesnt just produce a long page or wide page.

thanks in advance

Posted: Fri May 17, 2002 5:29 am
by volka

Code: Select all

for ($i=0; $i!=mysql_num_fields($result);$i++)
{
   if ($i!=0 && $i%4==0) print('<br>');
   print('<span>'.$result&#1111;$i].'</span>');
&#125;

Posted: Mon May 20, 2002 3:59 am
by knmwt15000
What? I don't get it.

come on guys. I use this code to output normally if this helps.

Code: Select all

<?php

$result = mysql_query("SELECT * FROM web_resources where category='journal' ",$db);

while ($myrow = mysql_fetch_array($result)) &#123;

		printf("
	<P class=normal><a href=%s>%s</a><br>
%s</p>
	
	\n",   $myrow&#1111;"webaddress"], $myrow&#1111;"name"], $myrow&#1111;"description"]);
&#125;
?>

Posted: Mon May 20, 2002 6:25 am
by volka
sorry, wasn't one of my better ones ;)

Code: Select all

<?php 
// ...<table><tr>
$result = mysql_query("SELECT * FROM web_resources where category='journal' ",$db);
$i=-1;
while ($myrow = mysql_fetch_array($result)) &#123; 
   if ($i==3) &#123; print('</tr><tr>'); $i=0; &#125; else $i++;
   printf("<td><span class="normal"><a href="%s">%s</a><br> 
%s</span></td>"
   , $myrow&#1111;"webaddress"], $myrow&#1111;"name"], $myrow"description"]); 
&#125; 
// ....</tr></table>
?>