PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
ianhull
Forum Contributor
Posts: 310 Joined: Tue Jun 14, 2005 10:04 am
Location: Hull England UK
Post
by ianhull » Sun Sep 17, 2006 5:17 pm
Hi Guys,
I have this
Code: Select all
$query = "SELECT id, module, companyname FROM modules WHERE companyname='$companyname'";
I need to get these results into two rows/columns on the page.
How would this be done?
Code: Select all
$result = mysql_query($query);
while ($line = mysql_fetch_array($result))
{
extract($line);
echo ' <table width="100%" cellspacing="2" cellpadding="2"><tr><td>'.$module.'</td><td>'.$module.'</td></tr></table> ';
}
Thanks in advance.
volka
DevNet Evangelist
Posts: 8391 Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger
Post
by volka » Sun Sep 17, 2006 5:26 pm
Code: Select all
$result = mysql_query($query) or die($query);
echo '<table><tr><th>table</th>';
$i = 0;
while ($row = mysql_fetch_array($result))
{
if ( 0==$i++%2 ) {
echo '</tr><tr>';
}
echo '<td>', htmlentities($row['module']),'</td><td>', htmlentities($row['module']), '</td>';
}
echo '</tr></table>';
see
http://www.php.net/manual/en/language.o ... hmetic.php