Page 1 of 1

White spaces tree structure..

Posted: Wed Dec 15, 2004 6:24 am
by localhost
i made this tree structure but there are white space on the pages how can i position these rows using css or what ever...

Code: Select all

<?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>"; ?>
			   <? }
		  ?>

?>

Posted: Wed Dec 15, 2004 12:52 pm
by rehfeld
if this is an html/css problem you might wanna provide the html and css

you tell us there is whitespace---where and how much? why?
you want help positioning it--how do you want it positioned?

you need to provide more info

Posted: Wed Dec 15, 2004 11:05 pm
by localhost
Take this row as an example The main link is Analysis and its subcategories are data analysis and financila analysis .....now its actually two rows white spaces that are unwanted ...i mean i want them to appear when i click analysis but they taking too much space...
<tr>
<td colspan='2'><p class='redp'><a href='#' onclick='MMDiv2.style.visibility="visible"';);'>Analysis
12</a></p>
</td>
</tr>
<tr>
<td>
<DIV ID="MMDiv2" 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>Data Analysis </p>
</td>
</tr>
<tr>
<td>
<tr>
<td align='right' width='20%'> <font size=3><strong>+</strong></font> </td>
<td width="80%">
<p>Financial Analysis </p>
</td>
</tr>
</table>
</LABEL>
</DIV>
</td>
</tr>
<tr>

Posted: Wed Dec 15, 2004 11:58 pm
by rehfeld
im still not very clear what you you mean

try removing the <p> tags
maybe thats where the space your talking about is coming from

Posted: Thu Dec 16, 2004 12:10 am
by localhost
i removed <p> tags it still didnt worked....let me put it this way after the main category link there are two rows of its subcategories which are in the div tag on clicking the main category link i make them visible but ....the problem is that when they are not visible they are still using the space of two rows....

Posted: Thu Dec 16, 2004 2:51 am
by CoderGoblin
Normally I use the css variable display to hide things. display:block; to show and display:none; to hide. This seems to work as required.

Posted: Thu Dec 16, 2004 10:02 pm
by rehfeld
oh ok makes sense now

do as codergoblin suggested

instead of
visibility: hidden;

use
display: none;

and to make it reappear use
display: block;

SOLVED

Posted: Fri Dec 17, 2004 1:53 am
by localhost
Thanks
that worked...