Jump to content

columns rather than rows?


therelelogo

Recommended Posts

Hi,

 

having stopped php for a while, i'm a little rusty, can someone help me - instead of the results returning in a row by row format, can i have it so it returns column by column?

so, rather than result 1 being first, then 2 underneath then 3 etc etc, can i have result 2 next to result 1?

 

heres my code

 

$result = mysql_query("SELECT * FROM members ORDER BY member_id DESC")   
or die(mysql_error());  

echo "<table border='2'>";
echo "<tr> <th></th> <th></th> <th></th> </tr>";
// keeps getting the next row until there are no more to get
while($row = mysql_fetch_array( $result )) {
// Print out the contents of each row into a table
echo "<tr><td>"; 
echo $row[printf('<img src="%s" height="96" width="128" style="border: 0" />', $row['profile_pic_short'])];
echo "</td><td>"; 
echo "<a href=\"PHP-Login/advert_pages/view_profile_specific.php?seller_name=$row[login]\">". $row['login'] . "</a>";
echo "</td></tr>"; 

} 

echo "</table>";
?>

 

all help appreciated

 

thanks

Link to comment
Share on other sites

Would something like this be what you're after?

 

$i = 0;
echo "<tr>"; 
while($row = mysql_fetch_array( $result )) {
  if ($i % 5 == 0)
    echo "</tr><tr>";
  // Print out the contents of each row into a table
  echo "<td>"; 
  echo $row[printf('<img src="%s" height="96" width="128" style="border: 0" />', $row['profile_pic_short'])];
  echo "</td><td>"; 
  echo "<a href=\"PHP-Login/advert_pages/view_profile_specific.php?seller_name=$row[login]\">". $row['login'] . "</a>";
  echo "</td>"; 
  $i++
}
echo "</tr>";

 

-jm

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.