drop down menu php options
-
Hi Alexander,
Any idea for when I need php code inside each option of a drop down menu for ‘selected’ attribute and then other chunks of php before and after the form all linked and working together, how should I use php_everywhere in this case without breaking the php execution order?
Here is the code:
<?php
$date=$_POST[‘selected_date’];
?><form action=”//url here” method=’post’> As of :
<select name=”selected_date”>
<option value=”2017-11-01″ <?php if ( $date == ‘2017-11-01’ ) {echo ” selected”;}?> >01.11.2017</option>
<option value=”2017-09-01″ <?php if ( $date == ‘2017-09-01’ ) {echo ” selected”;}?> >01.09.2017</option>
<option value=”2017-08-01″ <?php if ( $date == ‘2017-08-01’ ) {echo ” selected”;}?> >01.08.2017</option>
</select>
<input type=”submit” VALUE=”Get Data”/>
</form><?php
if($_POST[‘selected_date’])
$date=$_POST[‘selected_date’];
else
$date=”2017-11-01″; //default date upon 1st page load.
?>
- The topic ‘drop down menu php options’ is closed to new replies.