Results 1 to 4 of 4

Thread: Switch Menu PHP Query

  1. #1
    Join Date
    Jul 2006
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Switch Menu PHP Query

    1) Script Title: Switch Menu

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...switchmenu.htm

    3) Describe problem:

    I am trying to adapt this approach so that the menu items are listed using a PHP query and when clicking a menu item the records relating to it are displayed. Perhaps this will best be demonstrated through a page on my website:

    http://www.mindseyemidlands.co.uk/elearningcourses.php

    In my case I would like a list of quality systems to be the 'menu items' and when you click the menu item the details relating to it are 'expanded'.

    Here is my PHP query that at present lists the quality systems.

    PHP Code:
    include("connect.php"); 
    $sql "SELECT quality_name FROM qualityadmin WHERE category ='List A Generic Standards'";  
    $result mysql_query($sql) or die(mysql_error());  
    while(
    $row=mysql_fetch_array($result))  

    echo 
    '<a href="qualitysystem_summary1_details.php?quality_name='urlencode($row[0]) .'">'$row[0] .'</a><br><br>';  

    and here is the resulting query after clicking the chosen quality system

    PHP Code:
    if (isset($_GET['quality_name'])) { 
    include (
    "connect.php");

    $course mysql_real_escape_string($_GET['quality_name']); 
    $res "SELECT * FROM qualityadmin WHERE quality_name = '$quality_name'"
    $result mysql_query($res) or die(mysql_error()); 
    if (
    mysql_num_rows($result) > 0) { 
    while (
    $row mysql_fetch_assoc($result)) { 

    // begin output here: 

    echo '<style type="text/css"> 
    #myTable td { 
        font-family:arial, helvetica, sans-serif; 
        font-size: 14px; 
        } 
    .heading { 
        background:#eee; 
        color: #0000cc; 
        } 
    </style> 
    <table cellpadding="2" cellspacing="0" border="1" id="myTable" width="700px"> 
    <tr> 
    <td class="heading" colspan="3" fontsize= "18px">Quality Name</td> 
    </tr> 
    <tr> 
    <td colspan="3">' 
    $row['quality_name'] .'</td> 
    </tr> 
    <tr> 
    <td class="heading" colspan="4">Authority Body</td> 
    </tr> 
    <tr> 
    <td colspan="3">' 
    $row['authority_body'] . '</td>
    </tr> 
    <tr> 
    <td class="heading">Address 1</td> 
    <td class="heading">Address 2</td> 
    <td class="heading">Town</td> 
    </tr> 
    <tr> 
    <td>' 
    $row['address1'] . '</td> 
    <td>' 
    $row['address2'] . '</td> 
    <td>' 
    $row['town'] . '</td> 
    </tr> 
    <tr> 
    <td class="heading">Postcode</td> 
    <td class="heading">Telephone</td> 
    <td class="heading">Email</td> 
    </tr> 
    <tr> 
    <td>' 
    $row['postcode'] . '</td> 
    <td>' 
    $row['telephone'] . '</td> 
    <td>' 
    $row['email'] . '</td> 
    </tr> 
    How can I incorporate these queries so they function like the switch menu on Dynamic?

    Thanks in advance

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    PHP cannot be dynamic. It can populate your page with content before it is served to the browser. If you know how to get your content onto the page under normal circumstances (no switch menu script) then simply use PHP to populate both the hidden and visible parts of the menu. That's all you can do. You cannot populate the content 'on the fly' once a choice is made, it has to already be on the page before the script even starts working. This part is just like the script used without PHP.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Jul 2006
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by jscheuer1
    use PHP to populate both the hidden and visible parts of the menu.
    I see - im not sure what you mean by this though

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    I think I may have misunderstood your question. You just need to get them to write out in the form typically used by switch menu - as shown in step 2 on the demo page.

    You would get better specific help in the PHP forum on that I think, but, it is just a matter of writing out the type of HTML that the script expects.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •