我将我的数据库值存储在PHP文件中,如下所示:
$select->from(apartment,array('idapartment'));
$select->where('apartment.idowner = ?',$usersession->arrvar['idowner']);
$stmt = $select->query();
$result = $stmt->fetchAll();
$this->view->$rows = $options;
现在我想在一个phtml文件的下拉列表中使用它。任何人都可以帮我实现这个目标吗?
答案 0 :(得分:0)
在php文件中,您只需使用echo语句编写html代码。
如:
echo "<SELECT>";
for($i=0$i<count($result);$i++){
echo "<option>".$result[$i]['idowner']."</option>";
}
echo "</select>";
答案 1 :(得分:0)
这假设您将结果作为关联数组提取。如果您将它们作为对象提取,请使用$row->idapartment
代替$row['idapartment']
<select>
<?php foreach($this->rows as $row): ?>
<option value="<?php echo $row['idapartment']; ?>"><?php echo $row['idapartment']; ?></option>
<?php endforeach; ?>
</select>