-5

我将我的数据库值存储在 PHP 文件中,如下所示:

$select->from(apartment,array('idapartment'));   
$select->where('apartment.idowner = ?',$usersession->arrvar['idowner']);
$stmt = $select->query();   
$result = $stmt->fetchAll();
$this->view->$rows = $options;

现在我想在 phtml 文件的下拉列表中使用它。谁能帮我实现这个?

4

2 回答 2

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>
于 2012-09-11T17:26:44.137 回答
0

in a php file you simply write html code using the echo statement.

such as:

echo "<SELECT>";
for($i=0$i<count($result);$i++){
    echo "<option>".$result[$i]['idowner']."</option>";
}
echo "</select>";
于 2012-09-11T16:47:00.883 回答