Reputation: 3133
hello please me out while editing the drop down box value how we show the value from the previous database Like v do over here
`<input name="starttime" size="8" value="<?php echo $res['starttime'];?>" /`>
so how can i do same for this code
<select name="employee_id" id="employee_id" >
<option value="">Select</option>
<?php
$task = new Task();
$task->connect();
echo $emp = $task->getEmployee();
$task->disconnect();
?>
</select>
function getEmployee()
{
$this->query=("select * from employee");
$rd=$this->executeQuery();
while($row = mysqli_fetch_assoc($rd))
{
$pno = $row['pno'];
$name = $row['name'];
echo "<option value='$pno'>$name</option>";
}
}
}
if i put over here in the value value then it will take one its value but it will no show in the drop down box . so in short it pick value from the array and show in dropdown box
Upvotes: 0
Views: 356
Reputation: 3523
This will select your wanted value on your dropdown list.
echo "<option value='$pno'" . ($pno == $selectedValue ? " selected='selected'" : "") . ">$name</option>";
Upvotes: 1