Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Aug 2006
    Posts
    311
    Thanks
    0
    Thanked 1 Time in 1 Post

    Limiting tabular rows

    I can't seem to get this script to work I am trying to limit the rows to 4 but it keeps lining up 1 row on top of another. What am I missing?

    PHP Code:
     <?php
        $sr_no
    =0;
        
    $friends=$profile->get_front_friends($_SESSION["member_id"]);
        while(
    $friend_set=mysql_fetch_array($friends))
        {
              
    $fname=$people->get_name($friend_set["friend_id"]);

               
    $num_images=$people->get_num_images($friend_set["friend_id"]);
             if(
    $num_images==0)
             {
                 
    $gender=$people->check_gender($friend_set["friend_id"]);
                 
    $image=($gender=="Male") ? "<img alt='' src='images/male.gif' width='95' height='125' border=0>" "<img alt='' src='images/female.gif' width='95' height='125' border=0>";
             }
             else
             {
                
    $image_url=$people->get_image($friend_set["friend_id"]);
                
    $pic_name=str_replace('user_images/'''$image_url);
                
    $image "<img src='image_gd/image_profile.php?$pic_name' border='0'>";
             }
             
             
    $people_info=$people->get_info($friend_set["friend_id"]);
             
    $profile_info=$people->get_profile($friend_set["friend_id"]);
             
    ?> 
    <td align="center">
    <a href="view_profile.php?member_id=<?=$friend_set["friend_id"]?>"><?=$image?></a><br>
    <a href="view_profile.php?member_id=<?=$friend_set["friend_id"]?>"><?=$fname?></a><br>

    <?php
              $sql
    ="select status from online_now where member_id = $friend_set[friend_id]";
              
    $online_res=mysql_query($sql);
              
    $online_set=mysql_fetch_array($online_res);

              if(
    $online_set["status"]=="1")
              {
                 print 
    "<img src='images/onlinenow.gif'>";
              }

             print 
    "</td>";

             if(
    $sr_no%4==0)
             {
               print 
    "</tr><tr>";
             }

             
    $sr_no=$sr_no+1;
        }
    }
    ?>
        </tr>
        </table>

  • #2
    Regular Coder
    Join Date
    Apr 2003
    Location
    Montreal, QC
    Posts
    340
    Thanks
    3
    Thanked 2 Times in 2 Posts
    Try setting $sr_no to 1 at the very beginning. I think the problem is at the end with if($sr_no&#37;4==0) . With $sr_no starting at 0 the first row will be 5 columns long, and the rest will be 4, this may be bessing with your HTML. I by setting $sr_no to 1 at the beginning instead of 0 this will make each row only 4 columns long and hopefully fix the problem.
    Search for Laughter or Just Search?
    GiggleSearch.org
    Blog: www.johnbeales.com
    All About Ballet: www.the-ballet.com


  •  

    Posting Permissions

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