我正在处理的当前项目需要从数据库中检索数据。
我考虑过在html中使用select选项或下拉列表,使用javascript它会在文本字段中追加或设置文本,然后来自数据库的值。
function PopulateUserName() {
var dropdown = document.getElementById("iSupervisor");
var field = document.getElementById("iSupervisorUserName");
field.value = dropdown.value;
}
<?php
include('connection_phpmyadmin.php');
$result = $conn->query("select * from company_profile");
echo '<form action ="func/schedule_add.php" method="POST" enctype="multipart/form-data" >
<label>SELECT COMPANY NAME </label>';
echo '<select name="cp_id" id="iSupervisor" onchange="PopulateUserName()">';
while ($row = $result->fetch_assoc()) {
unset($b_id, $company_name);
$cp_id = $row['cp_id'];
$company_name = $row['company_name'];
$company_code = $row['company_code'];
echo '
<option value="'.$cp_id.'">'.$company_name.'</option>';
}
echo '</select>';
echo ' <input id="iSupervisorUserName" name="OBKey_WF_Manger_Supervisor_1" type="text" />';
echo " </form>";
?>
我的表格由cols
组成Can you please help me to view company_add and date added in input text field