0

<?php

$query=mysqli_query($con,"select * from reg where user_id = '".$_GET['id']."' ");
$row=mysqli_fetch_array($query);
?>

<select name="sex" id="opt2">
<option value="">select</option>
<option value="Male" selected="selected">Male</option>
<option value="Female" selected="selected">Female</option>
</select>

2
Contributors
4
Replies
44
Views
3 Years
Discussion Span
Last Post by chaitu11
0

Something like this might work.

<?php foreach($row as $reg): ?>
    <select name="sex" id="opt2">
    <option value="">select</option>
    <option value="Male" <?php if($reg['sex'] == 'Male'){echo 'selected="selected"';}?>>Male</option>
    <option value="Female" <?php if($reg['sex'] == 'Female'){echo 'selected="selected"';}?>>Female</option>
    </select>
<?php endforeach; ?>
0
<select name="state_id" id="states" class="form-control">
<?php 
$sql10= mysql_query("select * from states");
while($row10 = mysql_fetch_array($sql10)){
?>
<!-------------------------------edit-code----------------------------->
<option value="<?php echo $row10['state_id']; ?>"
<?php 
if(($row7['state_id'] == $row10['state_id'])){
echo 'selected = "selected"';
} ?>>
<?php echo $row10['state_name']; ?></option>
<?php
}
?>
</select>
0
<select name="yr">
<?php 
for($i=2005;$i<=date('Y');$i++){ ?>
?>
<!-------------------------------edit-code----------------------------->
<option value="<?php echo $row1['year1']; ?>"
<?php 
if(($row1['year1'] == $i)){
echo 'selected = "selected"';
} ?>>
<?php echo $i; ?></option>
<?php
}
?>
</select>
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.