Help me correct this code

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Help me correct this code

    Please anytime i want to display my members photo like 2 or 3 it always giving me more that what i wanted. Eg. I want to display 3 userz photo in random, it will display more than 50 images. Pls whats wrong.
    PHP Code:
    <?php 
     $usera
    =$db->get_row("SELECT * FROM b_users ORDER BY rand() DESC LIMIT 0,3");
    if(
    $usera)
    {
    foreach(
    $usera as $userd8)
    {
    if (!empty(
    $userd8->avatar)) 
    print 
    "<tr><td><div class=\"advert\"><img src=\"".$config->url."/avatars/".$userd8->avatar."\"
    width=\"70\" height=\"70\"> "
    ;
    //else, print gravatar
    else if($userd8->sex == "female") echo "<img src=\"".$config->url."/avatars/avatarf.png\" width=\"70\" height=\"70\"></img>"; else echo "<img src=\"".$config->url."/avatars/avatarm.png\" width=\"70\" height=\"70\"></img>";  
    }
    }
    ?>

    #2
    PHP Code:
     $usera=$db->get_row("SELECT * FROM b_users ORDER BY rand() LIMIT 3"); 

    Comment


      #3
      thanx man. but still not working... it still giving me multiple photos

      Comment


        #4
        PHP Code:
         $usera=$db->get_row("SELECT * FROM b_users ORDER BY RAND() LIMIT 0,3"); 

        Comment


          #5
          thanx let me try...

          Comment


            #6
            Originally posted by Devil223 View Post
            PHP Code:
             $usera=$db->get_row("SELECT * FROM b_users ORDER BY RAND() LIMIT 0,3"); 

            sorry i edited it before you tried it lol should be limit 3 not 0, 3

            Comment


              #7
              hmm, try both bt still not working

              Comment


                #8
                What are the symptoms?
                Try to remove foreach loop, in get_row should be while() already.
                Last edited by arnage; 24.03.12, 16:38.
                <!DOCTYPE html PUBLIC "-//WAPFORUM.RS

                Comment


                  #9
                  Can u give me da sample code using the while() loop

                  Comment


                    #10
                    PHP Code:
                    while ($usera mysql_fetch_array($userd8)) {


                    Comment

                    Working...
                    X