troubleshooting Question

How do i display row of 3 columns then rows of 4 columns ?

Avatar of zero525
zero525 asked on
10 Comments1 Solution367 ViewsLast Modified:

the code i have attached shows a function i have written in PHP to display a table of 3 columns and then move on to another row of 3 columns after the first 3 coumns are displayed, it all works fine but my question is how do i alter the function so that after the first 3 columns are displayed it then displays rows of 4 columns from then on ?
function NewestFans()

$sql="SELECT * FROM fans ORDER BY joined DESC LIMIT 0, 10";
$result = mysql_query($sql);

	$directory_self = str_replace(basename($_SERVER['PHP_SELF']), '', $_SERVER['PHP_SELF']);

echo '<table><tr>';
<td><img src="images/newUsers.png" alt="new users" width="116" height="116"></td>
$rows = 0;
while ($fans_newest_row = mysql_fetch_assoc($result)) {
  echo '<td width="80" height="80" valign="top"><a href="fan.php?fid=' . print_r($fans_newest_row['username'], true) . '">'. print_r($fans_newest_row['username'], true) .'</a><br />';
  $uploadsDirectory = $directory_self . 'include/users/' . $fans_newest_row['username'] . '/' . $fans_newest_row['p_pic'];
	<a href="fan.php?fid=<? echo $fans_newest_row['username']; ?>"><img src="<? echo $uploadsDirectory; ?>" border ="0" width="80" height="80"></a>
  echo '</td>';
  if ($rows %3 == 0) {
   echo '</tr><tr>';  
echo '</tr></table>';


Open in new window


Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 10 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 10 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros