473,734 Members | 2,647 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Dynamic DropDown Menu in PHP

5 New Member
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 "projectkir i" (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.
Jun 24 '09 #1
1 2662
dlite922
1,584 Recognized Expert Top Contributor
@sydd
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
Jun 24 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

7
3441
by: jorntk | last post by:
How can i make a drop down menu that are dynamiclly generated base on the value selected in another drop down menu? thanks nad regards Jorn
1
2552
by: Andrea Bampi | last post by:
I'm just trying to do my first experiments with js, but I need some good examples to start with.. I need to design a dynamic form with two dropdown menus picking their select values from a db: my problem is, how can I make the selection in the first menu affect the value list in the second, without using any buttons? I mean, you just have to click on the first menu and select the desired item, then the proper select list is "loaded" into...
3
10759
by: Robert Mark Bram | last post by:
Hi All! Has anyone seen an example of the following javascript powered control: - a dropdown select menu - the width of the control is set. Assume by "control" I mean the visible part of the drop down before a mouse click occurs. - the width of the list when selected is dynamic - the width of the list can grow beyond the width of the control without changing the width of the control.
7
4271
by: Bertman105 | last post by:
Hey all, Heres the situation: I have a form page that needs to have multiple drop down menus that is pulling their options from a database. Right now I have one working out of 3. So that is one issue, now the issue that I am having with the one that is working, is that it is not writing anything to the database. No matter what you select, the database is empty. Any help would be sweet. So here is the form page, with just a few text...
0
1411
by: Just Me | last post by:
My Dynamic dropdown menus are appearing above the text below. How can I prevent this, I have tried setting the zorder high for them, but it makes not difference. Cheers
4
2346
torquehero
by: torquehero | last post by:
Hi all :) I have created a horizontal navbar using Xara Menumaker. The Menu items have several dropdown menus. Its a javascript. When the mouse cursor is moved over any menu item, a dropdown list/menu appears. When the page is opened in the browser (as it appears by default), the dropdown menu positions are correctly displayed. But when I scroll the page and then move the mouse over any menu item of the navbar, the dropdown menu is not...
2
10298
by: William Youngman | last post by:
We are developing an application that presents data to the user in a gridview and we are using the dropdown extender to give the user a SharePoint 2007 type dropdown menu attached to the cells of a given column. We are also using another dropdown menu that the user can use to select data using another quesry using the SelectedIndex change method. Upon initial page load everything works fine and the user is presented with a SharePoint type menu....
1
3127
by: Steve Richter | last post by:
I am using <div align=centerto center a horizontal menu on the page. Problem is the center align of the div is rippling down to the menu items and causing the text of the dynamic popup sub menu items to be centered also. How can I center my navigation menu without centering the menu item text? thanks, -Steve
1
1918
by: phpnewbie2007 | last post by:
I have 2 dynamic PHP dropdowns: The second dropdown populates from the first, depending on what is selected in the first. The page is showing issues in a department: The first dropdown consists of departments- It has 3 options All issues, dept A, dept B If dept A is chosen in the first dropdown, the second dropdown shows all members in dept A and all issues are shown for dept A are shown below. Now if i choose a member in second...
0
8946
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8776
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9449
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9310
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9182
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8186
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6735
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
2
2724
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2180
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.