how do i set a dropdown menu to a get variable after refresh. there is an html menu and after a refresh i would like the dropdown to be set to the select variable. for example if i select 3 from the menu then click submit the dropdown should display 3. i used to do this with textboxes where i would set the value to the get variable im just trying to do this same technique with html dropdown menus.
</select>
<?php
$c=$_GET['c'];
$p=$_GET['p'];
$id=$_GET['id'];
if ($c!=NULL){
$sq=mysql_query("SELECT * FROM ps WHERE b='$id' AND c='$c'");
while ($row=mysql_fetch_assoc($sq)) {
$start=$row['start'];
$start=trim($start);
$m=$row['m'];
}
echo "<select type='text' name='pro' id='amount' value= '$p'>";
echo "<option value=''>P</option>";
while ($start<=$m){
echo "<option value='$start'>$start</option>";
$start++;
}
}
?>
</select>
Is this in a form? If so you echo options like this:
But first you need to submit the form though.
The idea is that you compare the value of a set variable for this select element to current value of $start within the loop, and print ‘selected’ if they match.