Jump to content

[SOLVED] Counter problem with i++ Or something wont move my users down ? :) Thanks help!


Recommended Posts

Here is my problem, im calling them from mysql, and letting them pop out like this:

 

15xps9x.gif

 

Only 1 problem that looks like shit, lol

 

I need a way to make it go:

 

 

 

2 Users show up on each line: kinda confusing? Well i mean like

 

Steve User1   <br>

 

User 2   User 3   <br>

 

User 9 User 10 <br>

 

I want ti nice and beautiful like that, BUT MY PHP Code is not making it do that it's making all there names scattered around like the above image!

 

here is my code :)

 

 

 

 

//monkuar
       // Buddy List - monkuar
       $rank = 'rank';
        {


        $DB->query("SELECT * FROM ibf_contacts c, ibf_members m WHERE member_id='".$member['id']."' AND c.contact_name=m.name ORDER By $rank LIMIT 6");







           while($r = $DB->fetch_row())



           {








//monkaur'd
       if ($r['desktop'])
           {
               $desktop = "<img src='{$r['desktop']}'>



               ";





           }
           else
           {
               $desktop = '';
           }
           //monkuar'd
   if ($r['monkavatar'])
           {
               $av = "

               </a><br><img src='{$r['monkavatar']}'  width='54' height='54' alt='' />
               ";
           }
           else
           {
               $av = '';
           }












               if($counter ==1) {$buddylist .= "<td>";}
               $buddylist .= "<div align=left></a><a href='index.php?showuser={$r['contact_id']}'>{$r['contact_name']}$desktop</a>$av</div>";
               if($counter++ >5) {$buddylist .="</td>";$counter=1;}
               else {$buddylist .= "";}
           }
       }

       if ($buddylist != "")
       {
           $this->output = str_replace( "<!-- Monkfriends -->", $buddylist, $this->output );
       }
       // Buddy List
       //monkuar

 

It output's it with this code:

 

if($counter ==1) {$buddylist .= "<td>";}
               $buddylist .= "<div align=left></a><a href='index.php?showuser={$r['contact_id']}'>{$r['contact_name']}$desktop</a>$av</div>";
               if($counter++ >5) {$buddylist .="</td>";$counter=1;}
               else {$buddylist .= "";}

 

 

 

Can you help me make it so it output's like this:

 

 

Steve User1   <br>

 

User 2   User 3   <br>

 

User 9 User 10 <br>

 

 

Thanks PHPFREAKS.COM !! please HEPL <3

 

 

 

 

[EDIT:] The image under steve just show's that a user has an Avatar :) srry about that.

No it's just the stupid:

 

if($counter ==1) {$buddylist .= "<td>";}

                $buddylist .= "<div align=left></a><a href='index.php?showuser={$r['contact_id']}'>{$r['contact_name']}$desktop</a>$av</div>";

                if($counter++ >5) {$buddylist .="</td>";$counter=1;}

                else {$buddylist .= "";}

 

it's not a css because it's just inside a basic fieldset tag dont worry about that worry about php plz, lol

 

This is what i want it to look like Thank u sir.

 

:

 

something like this xkuc6t.gif

 

And if they dont have a avatar it doesnt ruin it like my code does.

 

Eh. Someone needs to learn HTML. You have a closed A tag after a DIV when one is not opened.

 

I'm not going to even touch the code you posted because the spacing is far too messy.

 

But, here's what I'm thinking. You'll have to figure out how to put this into your code. You can do something like this:

 

$query = 'YOUR_QUERY';
$result = mysql_query($query) or die(mysql_error());

$output = '<table><tr>';
$count = 0;

while ($row = mysql_fetch_assoc($result)) {
     // 2 in a row
     if (!empty($count) && $count % 2 == 0) $output .= '</tr><tr>';
     $output .= '<td><a href="index.php?showuser=' . $row['contact_id'] . '">' . $row['contact_name'] . '</a><br /><img src="' . $row['desktop'] . '" /></td>';
     $count++;
}

$output .= '</tr></table>';

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.