Re: Need help to create HTML table with 2 columns.

From: Date: Thu, 23 Aug 2001 21:48:21 +0000
Subject: Re: Need help to create HTML table with 2 columns.
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-64183@lists.php.net to get a copy of this message
On 23 Aug 01, at 14:30, John Bass wrote: > <TABLE> > <?php > $query = "SELECT image_link, web_url FROM testdata"; > $result = mysql_query ($query) or die ("Query Failed"); > while ($row = mysql_fetch_object ($result)) > { > printf ("<tr><TD>%s<br>%s</TD> > <TD>%s<br>%s</tr>\n", $row->image_link, > $row->web_url,$row->image_link, $row->web_url); > } > ?> > </TABLE> Your 'while ($row...) is reading in one row of data. You're then outputing that one row of data twice. Is that what you wanted? You don't specifically say what it is that isn't working in this code so I'm really just guessing. If you're actually after a different set of data in each row then you're going to need to approach it differently. To have new data in the second column you'll basically have to add a flag to track if you've already put data on that row and then change the tags accordingly (if you've already got the start of the row, add the new column and end the row, otherwise start a row and add your data). CYA, Dave ----------------------------------------------------------------------- Outback Queensland Internet - Longreach, Outback Queensland - Australia http://www.outbackqld.net.au mailto:dfreeman@outbackqld.net.au -----------------------------------------------------------------------

« previous php.general (#64183) next »