简体   繁体   中英

PHP/CSS Dynamically populated Menus

I have been seeing a lot of your forums and thanks to your valuable help I managed to progress on an sql database I am currently developing. Unfortunately I am not sure whether I can handle it due to the fact I am no programmer but I have the will to learn and improve my skills. I started my project 4 weeks ago and arrived to a point where I cannot go further. Checked already the forum for something similar however my situation is not the same although for you all it might look very trivial. Basically I have a horizontal menu where the user is asked to choose an organisation (this is dynamically populated). Upon choosing the organisation using href link it directs you to a vertical menu which in turn is also dynamically populated.

The problem I am having is that I cannot make the second menu ie vertical open in the same page of the horizontal menu and I believe this is due to the href which is directing me to another php file. It could be that I need jquery or ajax to simultaneously show both menus however I am very green and un-experienced. Can someone give me a hint how can I progress?

here is some code snippets: code for horizontal menu

<?php
session_start();

mysql_connect('localhost','root','');
mysql_select_db('amds');
$sql="SELECT *FROM 3pxop_tb";

$opindex=mysql_query($sql);
?>

<body>
<div id="wrapper">
<div id="navmenu">

<ul>
<li><a href="#"><span><img src="images/plane.png" style="padding-top:4px;     width: 22px; height: 22px; margin:0"/> OPERATOR</a></span>

<ul>
<li><?php 
while($record=mysql_fetch_row($opindex))
{           
                if($_SESSION['$userID']==$record[3])
                {
                $count=0;
                $count=$count+1;
                $operator=$record[$count];
                echo "<a href=amdssidenav.php?phac=$record[0]>$organisation</a>";

                }       

}

echo"</li>";
echo "</ul>";
?>

"<" $userID is delivered when user logs in (used for credentials), goes into a while loop and finds out the organisations assigned by the $userID and automatically populates the menu. Upon clicking the href link passes the variable assigned to the chosen organisation to another php file which is used to populate the vertical menu.

code for vertical menu

   if(isset($_GET['phac']))   
   $opindex= $_GET['phac'];  

echo"<div id='container'>";

echo"<div class='sidebar'>";

{
echo "<ul id='nav'>";

        echo"<li>";


        while($record=mysql_fetch_row($acrecords))
        {     
                if($opindex==$record[4])
                { 
                    $count2=0;
                    $count2=$count2+1;
                    $product=$record[$count2];


                    echo "<a class='selected' href='detailsindex.php'>$product MSN($record[2])</a>";    


                 }

        }

echo"</li>";
echo "</ul>";
}

"<" Phac variable is passed from the first php file and is used for the second while loop which also dynamically populates by itself depending on the contents of the sql table. ">"

What I am trying hard to do funnily enough is to keep the two menus on the same web page and I believe why I am not successful is due to the use of href. The second menu will divert you to another php file.

Hiding/ showing divs is not a good alternative since depending what the user chooses from the second menu the contents in the central content page will change accordingly.

Hope it is somewhat clear :( and I apologise if I did not follow the rules to the letter but I am relatively new.

I thank you for your assistance.

Regards

Although this is not an answer, you could using a modal to display the second page, if it is only small, or an iframe . Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM