Tree structure Hiding white spaces....

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
localhost
Forum Commoner
Posts: 43
Joined: Tue Dec 07, 2004 4:52 am
Location: islamabad
Contact:

Tree structure Hiding white spaces....

Post by localhost »

i have completed the tree structre to show the info but the problem is that there are too many white spaces between the link ...how can postion them to hide these white spaces

[php<?
$result=mysql_query("select main_id,main_cat_detail from tbl_main_cat") or die(mysql_error());
$num=mysql_num_rows($result);
for($p=0,$i=0;$i<$num;$i++)
{
$id=mysql_result($result,$i,'main_id');
$title=mysql_result($result,$i,'main_cat_detail');
print "<tr><td colspan='2'><p class='redp'><a href='#' onclick='MMDiv$id.style.visibility=\"visible\"';);'>$title $i$p</a></p></td></tr>";
$result1=mysql_query("select s_cat_id,sub_cat_title from tbl_sub_category where main_id=".$id) or die(mysql_error());
$num1=mysql_num_rows($result1);
for($x=0;$x<$num1;$x++,$p++)
{
$sub_id=mysql_result($result1,$x,'s_cat_id');
$sub_title=mysql_result($result1,$x,'sub_cat_title');
//if(isset($sendid)&&$sendid==$id) ?>
<tr><td><? if($x==0){ ?>
<DIV ID="MMDiv<? print $id ?>" style="visibility:hidden">
<LABEL FOR="MakeModel">
<table id="MakeModel" width="100%"><? } ?><tr>
<td align='right' width='20%'>
<font size=3><strong>+</strong></font>
</td>
<td width="80%">
<p><? print "$sub_title </p>";
if($x==0&&$x+1!=$num1)
print "</td></tr>";
else if($x+1==$num1)
print "</td></tr></table></LABEL></DIV>";
else if($x==0&&$x+1==$num1)
print "</td></tr></table></LABEL></DIV>";
?>

<? }
print "</td></tr>"; ?>
<? }
?>

User avatar
CoderGoblin
DevNet Resident
Posts: 1425
Joined: Tue Mar 16, 2004 10:03 am
Location: Aachen, Germany

Post by CoderGoblin »

As far as I can see on a quick look you are using td width of 20% to set this. You could change this either to be less or alternatively change it to be a fixed width.

Personally I would change this to use CSS.

Regards
Post Reply