如果我正确理解您的问题,您希望将表单字段值相应地更改为所选值。这可以通过使用 javascript 或刷新页面并使用 PHP 加载的方式来实现。
使用 Javascript(jQuery) 的方法
<select name="pp" onchange="handleDroplistChange(this);">
<option>--Title--</option>
<?php
include('DBConnect.php');
$query = mysqli_query("SELECT * from table", $con);
while($row = mysqli_fetch_assoc($query)) {
?>
<option><?php echo $row['Teach_PPIJ_TNO']; ?></option>
<?php } ?>
</select>
<!-- other input to load after selecting value-->
<input id= "field1" type="text" name="field_name">
<script>
function handleDroplistChange(droplist)
{
var request = jQuery.ajax('somescript.php?selected_value='+droplist.value);
request.done(function(data){
var result = JSON.decode(data);
jq('#field1').val(result.field_name); // assuming that returning object with field names as attributes
});
}
</script>
使用刷新的方法
<select name="pp" onchange="window.location='somescript.php?selected_value='+this.value">
<option>--Title--</option>
<?php
include('DBConnect.php');
$query = mysqli_query("SELECT * from table", $con);
while($row = mysqli_fetch_assoc($query)) {
?>
<option><?php echo $row['Teach_PPIJ_TNO']; ?></option>
<?php } ?>
</select>
<!-- other input to load after selecting value-->
<?php
// load values according to selected value
$selected_value = $_GET['selected_value'];
?>
<input id= "field1" type="text" name="field_name" value="<?php echo $retrieved_value;?>">