简体   繁体   English

从下拉菜单中选择值

[英]selecting value from drop down dropdown

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 你好,请我在编辑下拉框值时出局,我们如何显示先前数据库中的值,就像v在这里做

`<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 简而言之,它从数组中选取值并显示在下拉框中

这将在下拉列表中选择所需的值。

echo "<option value='$pno'" . ($pno == $selectedValue ? " selected='selected'" : "") . ">$name</option>";

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM