Hi,

How can i design in php code drop down menu?

Thanks.

Recommended Answers

All 10 Replies

No. You cannot.

You can however, "design" the drop down menu in HTML and then process it using PHP.

ok,Thanks

Do you need any further help? I.e. a code snippet.

commented: yes i need code help..can you give me code but +0

I would be interested in seeing an example phorce if nobody else is. I'm looking at css to do it but looking at other methods will 'expand my horizons'. :) I'm colloecting examples for when it comes time to create my first WordPress theme.

@min2gether - I would stay away from WordPress IMHO

What kind of example would you like?

Member Avatar for diafol

Dropdown menus are typically CSS with some JS, or there are some pure CSS versions. If you search you'll find about half a gazillion hits.

@diafol Well as stated I am already looking at CSS @phorce I'm just interested in seeing an example of a dropdown menu written in html and how that is converted to PHP. Don't know why you would say stick clear of WordPress but each to their own I guess. With over 15% (and growing) of websites using WordPress it is among the easiest ways to have multi page CMS up and running in a relatively short space of time. Themes and skins are free in many cases and for beginners it overcomes many of the obstacles that stand in their way. Of course it does replace the need for HTML designers to some extent so maybe that's where you are coming from. Personally I had one site initially which gave me time to earn while I learn. If I had started with HTML or DHTML I may never have had a customised site for a year. But that's just my opinion. Maybe I should'nt be on DaniWeb. It's sounding like a site for programmers and not for those of us who are learning.

s among the easiest ways to have multi page CMS up and running in a relatively short space of time. Themes and skins are free in many cases and for beginners it overcomes many of the obstacles that stand in their way. Of course it does replace the need for HTML designers to some extent so maybe that's where you are coming from. Personally I had one site initially which gave me time to earn while I learn. If I had started with HTML or DHTML I may never have had a customised site for a year. But that's just my opinion. Maybe I should'nt be on DaniWeb. It's sounding like a site for programmers and not for those of us who are learning.

@mim2gether DaniWeb is for everyone, which, is what makes it so unique and that's why people come back (And of course stayed loyal!) it's not just for programmers, although, obviously, the majority will be programming since that topic is a major talking point for the visitors. This in mind, you should be here! If not to ask questions for yourself, or to answer questions that are posted by the users but to learn and adapt other coding techniques and standards from other programmers and developers (That's one of the points of programming, right?)!

As for WordPress, and, like you said - Each to their own! I personally developed a website / blog using Wordpress/BuddyPress and found it horrible to develop for. Yeah, I used the PHP/HTML etc and found it easier and quicker to use existing code I had already built to build my own platform. I do, however, agree that the platform has opened up to so many sites being developed and is widely used.. I sometimes wish they would improve on their overall platform!

As for the example, I'll give a fairly simple one..

Let's say I wanted a drop down menue for someones birthday.. And their age ranges were from, let's say (19-60), if I was to complete this in stand alone HTML/DHTML then it would take me a long time to write each individual value out, we can therefore use PHP to make our lives easier:

<form method="post" action="">
<select name="birthday">
<?php
  for($i=19; ($i < 60); $i++)
  {
       echo '<option value="' .$i. '">' .$i. '</option>';
  }
</select>
?>

The list would then be dynamically populated on the for loop. Another example would be to interact with a database in order to populate the drop-down menue.

Feel free to ask for more!

Member Avatar for diafol

Maybe I should'nt be on DaniWeb. It's sounding like a site for programmers and not for those of us who are learning.

No, everybody's welcome. We all started somewhere.

I'm just interested in seeing an example of a dropdown menu written in html and how that is converted to PHP

The menu will be written in HTML obviously or even HTML derived from PHP, but that won't make it a dropdown. Essentially you create a nested unordered list. It's the CSS (or the combination of CSS/JS) that turn it into a dropdown menu.

PHP doesn't do interactivity. Once the server sends the data to the client, that's it. JS on the other hand is meant for this.

@phorce...Thanks for the example. This would need to be set as a custom function in my custom.php file in the theme I use. Pulling the information from a database would be the next section I would imagine. I'm only just beginning to see the operation of php and I can see what appears to be the integer being set and added incrementally to the list. It's a subject I need to learn more about.

@diafol thank you for the input and I really love working with css. I'm purely a cut 'n' paste person and some of the sites online for practicing css are really helpful. It's quite amazing what you can find when you go looking as you say. The scariest thing is the js. I try to keep as little as possible in my own file as I managed top bring down my site on more than one occasion ..lol Easily fixed if you prepare yopurself not so easy if you don't as I found out.

I am fortunate to have a man by the name of Rick Anderson to ask when I'm in trouble. He has a membership site with live Q & A sessions on a regular basis. Thus my initial interest in Daniweb had waned due to the help I get. He writes plugins specifically for the Thesis Theme for WordPress and gives them to members so my js knowledge is limited. If I have a problem he can't help with this will always my next port of call. I just love reading here and taking ideas to him.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.