Reply
How can I output PHP query results in rows of three within table?
Old 04-16-2008, 04:11 AM How can I output PHP query results in rows of three within table?
drew22299's Avatar
Skilled Talker

Posts: 89
Location: Wiltshire, UK
Hi,

This might be a simple question, but I can't get it to work!

Currently my browse users page displays users stored in the database one after the other in line in the following way:

User1
User2
User3 etc

I tried moving the HTML table around that gets output with the user data returned from the database, but can't make it do the following:

User1 User2 User3
User4 User5 User6 etc

Here is the code I am using, what do I need to change?
Code:
 
 
echo "<TABLE border='0' bordercolor='red' cellspacing='0' bgcolor='red' cellpadding='4' align='center'><TR bgcolor='red'><TH><font color='white' face='arial'>Search results</font></TH><TH> </TH><TH> </TH><TH> </TH></TR>";
while($row = mysql_fetch_array($result)){
        //echo $row['userid']. " ". $row['name'];
        
       echo "<TR bgcolor='#f1f1f1'><TD><a href='view_profile.php?id=".$row['userid']."'><img src=".$row['imagelink']." width='125' length='125'></img></a></TD><TD><a href='view_profile.php?id=".$row['userid']."'>".$row['userid']."</a></TD><TD><a href='view_profile.php?id=".$row['userid']."'>".$row['name']."</a></TD><TD>" .$row['location']."<br></TD></TR><TR bgcolor='white'><TD> </TD></TR>"; 
       echo "<br /><br />";
}
echo "</TABLE>";
?>
__________________
www.hotlista.co.uk
drew22299 is offline
Reply With Quote
View Public Profile Visit drew22299's homepage!
 
When You Register, These Ads Go Away!
Old 04-16-2008, 06:09 AM Re: How can I output PHP query results in rows of three within table?
mtishetsky's Avatar
King Spam Talker

Posts: 1,062
Name: Mike
Location: Mataro, Spain
PHP Code:
<?
   $users 
get_users();
?>
<table>
<tr>
<?   foreach ($users as $k => $user): ?>
   <td><?= $user->name ?></td>
<?      if ($k && $k == 0): ?>
</tr>
<tr>
<?      endif ?>
<?   
endforeach ?>
</tr>
</table>
__________________
Free Mobile Phone Themes

And don't forget to give me talkupation!
mtishetsky is online now
Reply With Quote
View Public Profile Visit mtishetsky's homepage!
 
Old 04-17-2008, 04:21 PM Re: How can I output PHP query results in rows of three within table?
drew22299's Avatar
Skilled Talker

Posts: 89
Location: Wiltshire, UK
Thanks
__________________
www.hotlista.co.uk
drew22299 is offline
Reply With Quote
View Public Profile Visit drew22299's homepage!
 
Reply     « Reply to How can I output PHP query results in rows of three within table?
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.11436 seconds with 12 queries