...

View Full Version : Limiting tabular rows



Jacobb123
01-07-2008, 11:29 AM
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
$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>

johnnyb
01-07-2008, 03:17 PM
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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum