raj_2006
08-04-2006, 08:05 AM
Hi All,
I am making a dynamic menu using php/mysql.I want to display the below output
Country[label]
US
.....Ohio
Spain
.....Barcelona
If i click US then it will show ohio or if i click Spain then it will show Barcelona...this is the objective.Now i have written the code in this way
<tr>
<td>Country>></td>
</tr>
<?
$chk="select * from juri where parent_id='0'";
$q_chk=mysql_query($chk) or die(mysql_error());
$tot=mysql_num_rows($q_chk);
?>
<tr>
<td><a href="index.php?type=cat">Add Country</a></td>
</tr>
<?
while($row1=mysql_fetch_array($q_chk))
{
$name=$row1['name'];
$master_id=$row1['master_id'];
$parent_id=$row1['parent_id'];
?>
<tr>
<td> <a href="index.php?show=subcat&master_id=<?=$master_id;?>">
<?=$name;?>
</a> </td>
</tr>
<?
if($_GET['show']=="subcat")
{
$master_id=$_GET['master_id'];
$mas_sql="select * from juri where parent_id='$master_id'";
$mas_q=mysql_query($mas_sql) or die(mysql_error());
while($row2=mysql_fetch_array($mas_q))
{
?>
<tr>
<td>.....
<?=$row2['name'];?>
</td>
</tr>
<?
} }}?>
Now after running the above code i am getting this output
Country[label]
US
.....Ohio
Spain
.....Ohio
I think it might be a problem of 2nd loop or somethng else.....really i dont have the idea.
Please suggest me a idea so that i can display the desired output
thanks for your suggestion in advance.........Raj
I am making a dynamic menu using php/mysql.I want to display the below output
Country[label]
US
.....Ohio
Spain
.....Barcelona
If i click US then it will show ohio or if i click Spain then it will show Barcelona...this is the objective.Now i have written the code in this way
<tr>
<td>Country>></td>
</tr>
<?
$chk="select * from juri where parent_id='0'";
$q_chk=mysql_query($chk) or die(mysql_error());
$tot=mysql_num_rows($q_chk);
?>
<tr>
<td><a href="index.php?type=cat">Add Country</a></td>
</tr>
<?
while($row1=mysql_fetch_array($q_chk))
{
$name=$row1['name'];
$master_id=$row1['master_id'];
$parent_id=$row1['parent_id'];
?>
<tr>
<td> <a href="index.php?show=subcat&master_id=<?=$master_id;?>">
<?=$name;?>
</a> </td>
</tr>
<?
if($_GET['show']=="subcat")
{
$master_id=$_GET['master_id'];
$mas_sql="select * from juri where parent_id='$master_id'";
$mas_q=mysql_query($mas_sql) or die(mysql_error());
while($row2=mysql_fetch_array($mas_q))
{
?>
<tr>
<td>.....
<?=$row2['name'];?>
</td>
</tr>
<?
} }}?>
Now after running the above code i am getting this output
Country[label]
US
.....Ohio
Spain
.....Ohio
I think it might be a problem of 2nd loop or somethng else.....really i dont have the idea.
Please suggest me a idea so that i can display the desired output
thanks for your suggestion in advance.........Raj