Hi everyone,
my menu tree is not working and I whish to work with dynamic variables. I
list categories and when clicked upon the tree has to show the sublist and
if clicke upon the pages.
I want to parse the variable c1=1 to expand category one c2=1 for category 2
etc. I'm having trouble defining my if function to do this. I'm capable of
extending one tree by using c=1, but the the can not have 2 trees expanded.
My poblem is the if statement.
Please help!!!!!
my script (in parts):
<?php
mysql_connect(host,user,pass)
or die("Could not connect: " . mysql_error());
mysql_select_db(my_database)
or die("could not select db: " . mysql_error());
$count="select * from category";
$result=mysql_query($count);
$num_rows=mysql_num_rows($result); //counts number of categories
while ($a_row=mysql_fetch_array($result)){ //lists categories
///////////////now to display the with a link I use this line:
print "<a
href='test.php?$QUERY_STRING&c$a_row[0]=1'>".$a_row['category']."</a><br>";
//////////////this prints a link that passes c1=1 if clicked on 1st link
and c2=1 on second etc.
/////////////it also passes previous query so that more trees can be
extended
/////////////here comes my problem:
if ($c.$a_row[0]==1){
//////////////this should check if c1=1 the first time round and
c2=1 the secound time around etc. but it doesn't work
/////////////then if c1=1 list the subs from 1 etc.
$count2="select * from sublist WHERE category=".$a_row['id']."";
$result2=mysql_query($count2);
$num_rows2=mysql_num_rows($result2);//counts number of sublists
while ($a_row=mysql_fetch_array($result2)){//lists sublists
/////////////once again a link to expand subtree this time using
s1=1 etc.
print "<a
href='test.php?$QUERY_STRING&s$a_row[0]=1'>".$a_row['subname']."</a><br>";
if($s.$a_row[0]==1){
////////expanded subtree
$count3="select * from pages WHERE
sublist=".$a_row['id']."";
$result3=mysql_query($count3);
$num_rows3=mysql_num_rows($result3);//count number of pages
in sublist
while ($a_row=mysql_fetch_array($result3)){//lists pages
///////////link to the actual page
print "<a
href='linktopage'>".$a_row['pagename']."</a><br>";
}
}
}
}
}
?>