i have a form that submits 2 values to my database, when the form loads i check if there is already values in the database, i’ve been trying to use these values and set them as default on my dropdown boxes. any help would be appreciated. thanks
<form method="post" action="add_res.php?id=<? echo $id;?>">
<fieldset>
<label>From</label>
<select name='one' id='one'>
<?
for($hours=0; $hours<24; $hours++) // the interval for hours is '1'
for($mins=0; $mins<60; $mins+=30) // the interval for mins is '30'
echo '<option>'.str_pad($hours,2,'0',STR_PAD_LEFT).':'.str_pad($mins,2,'0',STR_PAD_LEFT).'</option>';
?>
</select><br><br>
<select name='two' id='two'>
<?
for($hours=0; $hours<24; $hours++)
for($mins=0; $mins<60; $mins+=30)
echo '<option>'.str_pad($hours,2,'0',STR_PAD_LEFT).':'.str_pad($mins,2,'0',STR_PAD_LEFT).'</option>';
?>
</select>
</fieldset>
<input type="submit" value="Restrict" class="btn_searchp"></a>
</form>
you have to combine the value and then compare with database value
References :
sprintfternary operator