Reputation: 135
Here is my code for my drop down menu. On one server, the appropriate numbers are shown. But on another, I am seeing ">" for each choice in the drop down menu. I'm guessing this has something to do with the php.ini file, but I'm not sure...
<?php
// connect to the database
require 'connect.php';
// -------------------------------------------------------------------------------------------------------
// Drop Down Menu to choose Start and End dates
$startyear = "";
$startmonth = "";
$startday = "";
$endyear = "";
$endmonth = "";
$endday = "";
// Array of values for form
$year = range(1998,2012);
$month = range(01,12);
$day = range(01,31);
if($_SERVER['REQUEST_METHOD']=='POST')
{
foreach($_POST as $key=>$value)
{
if(is_numeric($value))
{
$$key = $value;
}
}
}
?>
<form name='update' action='' method='POST'>
Start: <select name='startyear'>
<?php foreach(array_reverse($year) as $y):?>
<option value="<?=$y?>"<?=((isset($startyear) && $startyear == $y)?' selected':null)?>><?=$y?></option>
<?php endforeach;?>
</select>
<select name='startmonth'>
<?php foreach($month as $m): $m = str_pad($m, 2, "0", STR_PAD_LEFT);?>
<option value="<?=$m;?>"<?=((isset($startmonth) && $startmonth == $m)?' selected':null)?>><?=$m;?></option>
<?php endforeach;?>
</select>
<select name='startday'>
<?php foreach($day as $d): $d = str_pad($d, 2, "0", STR_PAD_LEFT);?>
<option value="<?=$d;?>"<?=((isset($startday) && $startday == $d)?' selected':null)?>><?=$d;?></option>
<?php endforeach;?>
</select>
<br>
End: <select name='endyear'>
<?php foreach(array_reverse($year) as $y):?>
<option value="<?=$y?>"<?=((isset($endyear) && $endyear == $y)?' selected':null)?>><?=$y?></option>
<?php endforeach;?>
</select>
<select name='endmonth'>
<?php foreach($month as $m): $m = str_pad($m, 2, "0", STR_PAD_LEFT);?>
<option value="<?=$m;?>"<?=((isset($endmonth) && $endmonth == $m)?' selected':null)?>><?=$m;?></option>
<?php endforeach;?>
</select>
<select name='endday'>
<?php foreach($day as $d): $d = str_pad($d, 2, "0", STR_PAD_LEFT);?>
<option value="<?=$d;?>"<?=((isset($endday) && $endday == $d)?' selected':null)?>><?=$d;?></option>
<?php endforeach;?>
</select>
<input type='submit' value='View'/>
</form>
Upvotes: 0
Views: 287
Reputation: 6389
Change:
selected':null)?>><?=$y?></option>
to
selected':null)?><?=$y?></option>
There are too many >
Upvotes: 1
Reputation: 10732
Try swapping the short PHP tags for the long ones.
<?=
becomes <?php echo
And
<?
becomes <?php
Some configurations let you use the short forms; all PHP configurations let you use the longer ones.
Upvotes: 2