I need the solution on making an option "selected" on some conditions given by $_GET[]. The idea is.
<?
$sql_id="select * from stock order by id asc";
$result_id=mysql_db_query($dbname,$sql_id);
while($rec_id=mysql_fetch-array($result_id)){
$_id=$rec_id['id'];
$_title=$rec_id['title'];
if($_GET['id']==$_id){
echo "<option value=\"$_id\" selected>$_title</option>";
}else{//I need this option selected where id='2'
echo "<option value=\"$_id\">$_title</option>";
}
?>
The question is : I also need the empty($_GET['id'])=2 as well. Then the conditions would be
- Select an option when $_GET['id']==$_id
- Select an option from mysql (where stock.id='2') when $_GET['id']==""