how to create drop down list in php

i m new to php , i want to create a drop down menu which contain other

Page 1 of 1

2 Replies - 43773 Views - Last Post: 03 February 2008 - 12:14 PM Rate Topic: -----

#1 zair  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 03-February 08

how to create drop down list in php

Posted 03 February 2008 - 08:56 AM

:)
Is This A Good Question/Topic? 0
  • +

Replies To: how to create drop down list in php

#2 Mike007  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 7
  • View blog
  • Posts: 332
  • Joined: 30-August 07

Re: how to create drop down list in php

Posted 03 February 2008 - 12:05 PM

Looks to me like a HTML question more than it is a PHP one, but you do it something like this:

<select name="mydropdownlist">
<?php
	$options = array('option1' => 'option 1'
				 'option2' => 'option 2'
				 'option3' => 'option 3');

	foreach($options as $value => $caption)
   {
		echo "<option value=\"$value\">$caption</option>";
   }
?>
</select>



In HTML you use the select tag name to create a drop down list and the option tag to create the values that will go into that list. In PHP I just used the associative array to create a list of values then looped through all of them and outputed them in HTML.

Enjoy :) .

This post has been edited by Mike007: 03 February 2008 - 12:10 PM

Was This Post Helpful? 0
  • +
  • -

#3 aj32  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 30
  • View blog
  • Posts: 577
  • Joined: 30-August 07

Re: how to create drop down list in php

Posted 03 February 2008 - 12:14 PM

If you are able to use HTML or DHTML, this program is very useful:

http://www.coffeecup.com/free-dhtml/

I don't know of any like that for php.

Cheers, Aj32! :)

This post has been edited by aj32: 03 February 2008 - 12:14 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1