Jump to content

PHP Drop Down menu will not show array value?


Dicko_md

Recommended Posts

$array = array("3", "6", "12", "18", "24");

$opt = '';
	for ($i=0; $i<sizeof($array); $i++) $opt .= "<option value='$array[i]'> $array[i] </option>";
	$html = "
		<form method='get' action='index.php?s=upgrade'>
		<input type='hidden' name='s' value='upgrade' />
		<input type='hidden' name='memid' value='$_GET[memid]' />
		<span class='formlabel'>Months:</span> <select name='nummonths'>$opt</select> 
<input type='submit' class='button' value=' Submit ' name='gopay'>
		<br /><br />
		</form>
	";

The above code should show 3, 6, 12, 18, 24 in a drop down menu but it is only showing 5 blank spaces.

 

Can anyone spot what I have done wrong ? If I put anyMonths in the $array between the options like below theMonths shows up on all 5 lines of the drop down

$opt .= "<option value='$array[i]'> $array[i] Months </option>";

Thanks 

 

Martyn

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.