我解决了这个问题,所以我想分享解决方案。希望这可以帮助想要填充组合框的人。
try{
$conn = new PDO('mysql:host=Jamal-PC;dbname=japanesewords',$username,$password);
$sql ='SELECT id, Englishword FROM Japanesedefinition;';
$stmt = $conn->prepare($sql);
$stmt ->execute();
$data = $stmt->fetchAll(PDO::FETCH_ASSOC);
select name="Japanese" id="Japanese">
<?php foreach($data as $row) : ?>
<option value="<?php echo $row['id']; ?>"><?php echo $row['Englishword']; ?></option>
<?php endforeach ?>
</select>