SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast Ben Wilkins's Avatar
    Join Date
    Mar 2006
    Location
    England, United Kingdom
    Posts
    67
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Make a table go to the next row when the MYSQL result is every 8

    Quite hard to explain.

    http://puu.sh/1tcvn

    On the picture you see that I have the table, and I need to make it so on the 8th result it puts it down to a new row.

    PHP Code:
    <table align='left' width='100' height='130' border='1'>
      <tr>
    <?php


       $account 
    $_SESSION['SESS_FIRST_NAME'];


    $username mysql_query("SELECT * FROM accounts where username = '$account'")
    or die(
    mysql_error());  

    while(
    $row mysql_fetch_array$username )) {
        
    $id $row['id'];

        
        } 

    // Get all the data from the "example" table
    $result mysql_query("SELECT * FROM characters  ORDER by active DESC"
    or die(
    mysql_error());  


    // 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
        
    $skin $row['skin'];
        
    $name $row['charactername'];
        
    $cash $row['money'];    
        
    $lastarea $row['lastarea'];    
                        
    $name2 str_replace("_"" "$name);
        
    $bankmoney $row['bankmoney'];
        
    $characterid $row['id'];    

        
    $totalmoney $cash +$bankmoney;
        
    $cked $row['cked'];    
        
    $active $row['active'];
        
    $cked2 str_replace("0""<font color=\"#009900\">Alive</font>"$cked);
        
    $cked3 str_replace("1""<font color=\"#CC0000\">Dead</font>"$cked2);
        
    $cked4 str_replace("2""<font color=\"#CC0000\">Dead</font>"$cked3);
        
        
    $deactivated "<font color=\"#CC0000\">Deactivated</font>";
        


        echo 
    "
      
        <td height='56' colspan='2'><center><a href=\"./characters.php?id=
    $characterid\">"; if($active == 1){ echo "<img  border=\"0\" width='85' height='78' src=\"./img/skins/$skin.png\">"; } else { echo "<img style='opacity:0.2;' border=\"0\" width='85' height='78' src=\"./img/skins/$skin.png\">"; } echo "</a><br /><b><font  size='2' color='#555'>$name2</font></b><br /><font size='1'><i>"; if($active == 1){ echo $cked4"; } else { echo $deactivated; } echo " </i></font></center></td>
    "





    ?>  </tr>


    </table>
    NSGclan.com | RECRUITING NOW! | Multi-gaming clan

  2. #2
    From space with love silver trophy
    SpacePhoenix's Avatar
    Join Date
    May 2007
    Location
    Poole, UK
    Posts
    5,014
    Mentioned
    103 Post(s)
    Tagged
    0 Thread(s)
    Set up a variable called say $count which would be set as 0 before the loop starts, each iteration 1 would be added to the count. With in if block you would check to see if $count is equal to 8, if it is the current row would be "closed" and a new row started, plus $count would be reset.
    Community Team Advisor
    Forum Guidelines: Posting FAQ Signatures FAQ Self Promotion FAQ
    Help the Mods: What's Fluff? Report Fluff/Spam to a Moderator


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •