$result实际上是一个数组,如下所示:
阵列(21世纪的book_title =>生物伦理学,id => 1424 isbn => 978-953-307-270-8 unix_name => - in -21世纪的生物伦理学( visible_online => 1))
这是我的观点(更好的said...poor视图尝试)。我试图根据数组的索引来获得对齐。就像这样:http://pastebin.com/z13PZWe8
<table class="datagrid grid_collapsible" width="100%" cellpadding="2" cellspacing="0" id="webbooks_table">
<thead>
<tr class="datagrid_header"
<td>Book title</td>
<td>ID</td>
<td>ISBN</td>
<td>Is it visible online?</td>
</tr>
</thead>
<tbody>
<?php foreach($this->basicBwDetails as $result): ?>
<tr>
<td><?=$result;?> </td>
</tr>
<?php endforeach; ?>
</tbody>
</table>谢谢你的帮助!
发布于 2011-12-12 11:39:51
你想这么做吗?
<table class="datagrid grid_collapsible" width="100%" cellpadding="2" cellspacing="0" id="webbooks_table">
<thead>
<tr class="datagrid_header">
<td>Book title</td>
<td>ID</td>
<td>ISBN</td>
<td>Is it visible online?</td>
</tr>
</thead>
<tbody>
<?php foreach($this->basicBwDetails as $result): ?>
<tr>
<td><?php echo $result['book_title']; ?></td>
<td><?php echo $result['id']; ?></td>
<td><?php echo $result['isbn']; ?></td>
<td><?php echo ($result['visible_online']) ? 'Yes' : 'No'; ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>另外,应该避免使用<?=$var;?>语法,因为在许多short_open_tag安装中禁用了short_open_tag,这是在PHP5.4.0之前必须使用的语法
发布于 2011-12-12 11:35:17
取决于您是如何从数据库中获得结果的,它将如下所示:
<td><?=$result['book_title']?> </td>
<td><?=$result['id']?> </td>
<td><?=$result['isbn']?> </td>
<td><?=$result['visible_online']?> </td>或者如果你在使用教义:
<td><?=$result->book_title?> </td>
<td><?=$result->id?> </td>
<td><?=$result->isbn?> </td>
<td><?=$result->visible_online?> </td>您应该阅读教程,类似于它中的内容:) http://framework.zend.com/manual/en/zend.db.statement.html
发布于 2011-12-12 11:37:46
...
<tbody>
<?php foreach($this->basicBwDetails as $result): ?>
<tr>
<?php foreach($result as $cell)?>
<td><?=$cell;?> </td>
<?php endforeach; ?>
</tr>
<?php endforeach; ?>
</tbody>
...像这样?
https://stackoverflow.com/questions/8473588
复制相似问题