Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

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>';

Avatar of blueghozt
blueghoztFlag of United Kingdom of Great Britain and Northern Ireland image

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

This problem has been solved!
Unlock 1 Answer and 10 Comments.
See Answers