Connecting Tech Pros Worldwide Help | Site Map

Dynamic DropDown Menu in PHP

  #1  
Old June 24th, 2009, 06:54 AM
Newbie
 
Join Date: Jun 2009
Posts: 5
Hi,

I was wondering if it's possible to create a dynamic dropdown menu from this code.

Expand|Select|Wrap|Line Numbers
  1. if($rs->getNumRows() > 0){
  2.                     $intProjectCount = 1;
  3.                     $htmlOut ="<table width='100%'  border='0' align='center' cellpadding='1' cellspacing='0'>";
  4.                     foreach($rs->fetch() as $prs){
  5.  
  6.                         $htmlOut .="<tr><td class=\"projectkiri\" ><a href=\"/index.php?page=PROJECTS&id=".$prs['pr_ID']."\">".$prs[$strFieldName]."</a></td></tr>";
  7.                         //$intProjectCount++;
  8.                     }
  9.                      $htmlOut .="</table>";
  10.                 }else{
  11.                     $htmlOut ="<table width='100%'  border='0' align='center' cellpadding='1' cellspacing='0'>";
  12.                     $htmlOut .="<tr>
  13.                             <td class='projectkiri'>Belum ada proyek <br>untuk saat ini</td>
  14.                           </tr>
  15.                         </table>";
Basically, if I understood this correctly, this snippet of code
Expand|Select|Wrap|Line Numbers
  1.                         $htmlOut .="<tr><td class=\"projectkiri\" ><a href=\"/index.php?page=PROJECTS&id=".$prs['pr_ID']."\">".$prs[$strFieldName]."</a></td></tr>";
makes sure the "projectkiri" (project-menu on the left of the page) is displayed. Meaning the different projects listed in the CMS. Now, as it's 5 projects, I want that as soon as you mousehover above the selected project, a sub-menu consisting of 4 different submenus to appear (We've already got the sub-pages incorporated, I just want a sub-menu for easier access).

So hover above project 1, the four sub-menus for project 1 appear, same for project 2 etc.. Is this actually possible? I tried it myself but somehow the dropdown menus didn't appear when you mouse-over'd but they were constantly there. Also when I used <ul> and <il> tags in the $htmlOut I kept getting a parse/syntax error everywhere.

Thanks in advance.
  #2  
Old June 24th, 2009, 04:49 PM
dlite922's Avatar
Expert
 
Join Date: Dec 2007
Location: Moon, Dark Side
Posts: 1,075

re: Dynamic DropDown Menu in PHP


Quote:
Originally Posted by sydd View Post
..the dropdown menus didn't appear when you mouse-over'd but they were constantly there...
This is a CSS issue. The mouseover event and the display format/behaviors of the page are controlled on the client side. PHP uses the server to output browser code (HTML, JavaScript, CSS, etc).

I'm assuming you have for menu items (4 projects let's say) and when you mouse over each project menu, a drop down list of sub-items for that project should appear?

If this is correct, than you need a dynamic drop down menu. There are many codes online if you don't want to create your own. Once you have that, you echo the values of the items with PHP.

Hope that makes sense to you,




Dan
Reply


Similar Threads
Thread Thread Starter Forum Replies Last Post
Getting 2 errors in IE7 (win xp) for dropdown menu nrose answers 1 January 17th, 2008 11:10 AM
a can anybody help me on how to make dynamic popup menu johnix answers 1 March 30th, 2007 05:21 PM
Dynamic dropdown menu to database Bertman105 answers 7 November 21st, 2006 03:36 PM
dropdown menu problem Ian Davies answers 2 November 23rd, 2005 03:08 AM