Reputation: 453
I'm trying to do a dynamic drop down menu. First I read from a sql table some dates and them I want to print the dates in a drop down box and select one. I can print them, but I can't seem to select one. This is my code on the relevant part:
?>
<form action="dataProc.php" method="POST">
<select id="dates" name="dates">
<option value="0">--Selecionar Dia--</option>
<?php
for($i = 0 ; $i < count($resultados) ; $i++)
{
?>
<option value="<?php $i ?>"><?php echo $resultados[$i]['anoDia'] ;?></option>
<?php
}
?>
</select>
<input type="submit" value="Escolher">
</form>
<?php
if(isset($_POST['dates']))
{
if(empty($_POST['dates']))
{
echo 'ya';
}
else
{
echo $_POST['dates'].'<br>';
}
}
EDIT: manage to solve my problem. Just changed <?php $i ?>
to <?php echo $resultados[$i]['anoDia'] ;?>
Upvotes: 1
Views: 119