Wrox Programmer Forums
|
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 25th, 2011, 01:13 PM
Authorized User
 
Join Date: May 2010
Posts: 70
Thanks: 4
Thanked 6 Times in 6 Posts
Send a message via Yahoo to GeneBuchite
Default Arrays

This Code will Place January in the pulldown menu, but Feb-Dec Are place as text beside the pulldown menu... How Do I get the whole array into the pulldown menu?

Code:
 <?php # Script 3.7 - Beef.php
function make_calendar_pulldowns(){
// Make th emonths array
$months = array(1 => 'January', 'Feburary', 'March', 'April','May','June','July','August','September','October','November','December');

// Make the months pull down menu

echo '<select name="month">';
foreach ($months as $key => $value) {

     echo "<option value=\"$key\">
     $value</option>\n";

     echo '</select>';
}



}// End of the function definitoin

//create the form tags

  echo '<h1>Select a Date:</h1>

<form action = "Beef.php" method = "post">';

// Call the function

make_calendar_pulldowns();

echo '</form>';

?>
 
Old August 26th, 2011, 06:54 AM
Friend of Wrox
 
Join Date: May 2011
Posts: 125
Thanks: 0
Thanked 24 Times in 24 Posts
Default

Greetings,

Code:
<?php
/*
	Script 3.7 - Beef.php
*/

//create the form tags
echo '<h1>Select a Date:</h1>';
echo '<form action = "Beef.php" method = "post">';

// Call the function
echo make_calendar_pulldowns();

echo '</form>';


// Function
function make_calendar_pulldowns()
{
	// Make th emonths array
	$months = array('January', 'February', 'March', 'April','May','June','July','August','September','October','November','December');

	// Make the months pull down menu

	$the_select = '<select name="month" size="1">' ."\n";
	foreach ($months as $value)
	{
		$the_select .= '<option value="' . $value . '">' . $value . '</option>' . "\n";
	}
	$the_select .= '</select>';
	
	return $the_select;
}

?>
The Following User Says Thank You to UseLess For This Useful Post:
GeneBuchite (August 27th, 2011)
 
Old August 27th, 2011, 06:27 AM
Authorized User
 
Join Date: May 2010
Posts: 70
Thanks: 4
Thanked 6 Times in 6 Posts
Send a message via Yahoo to GeneBuchite
Default Arrays

Why... Why Do I ever purchase books published by other publishers than WROX????? There Are SOOOOOOOOO. Many errors in my book. You'd Think I'd Learn. THanks for the help





Similar Threads
Thread Thread Starter Forum Replies Last Post
arrays ozPATT Excel VBA 2 November 4th, 2005 06:11 AM
Multidemmesional Arrays OR arrays gmoney060 Classic ASP Basics 3 November 1st, 2004 03:42 PM
Arrays tajin Excel VBA 0 June 20th, 2004 09:07 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.