Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

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

Posts: 93
Trades: 0
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>";
?>
drew22299 is offline
View Public Profile
 
 
Register now for full access!
Old 04-16-2008, 07:09 AM Re: How can I output PHP query results in rows of three within table?
mtishetsky's Avatar
King Spam Talker

Posts: 1,226
Name: Mike
Location: Mataro, Spain
Trades: 0
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>
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE

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

Posts: 93
Trades: 0
Thanks
drew22299 is offline
View Public Profile
 
Closed Thread     « Reply to How can I output PHP query results in rows of three within table?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB 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.11688 seconds with 12 queries