将数组放入 html 表中
$result 实际上是一个数组,如下所示:
Array ( [book_title] => 21 世纪的生物伦理学 [id] => 1424 [isbn] => 978-953-307-270-8 [unix_name] => 21 世纪的生物伦理学 [visible_online] => 1)
这是我的观点(更好地说......观点的糟糕尝试)。我正在尝试根据数组的索引进行对齐。就像这样: 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>
感谢您的帮助!
$result is actually an array which looks like this:
Array ( [book_title] => Bioethics in the 21st Century [id] => 1424
[isbn] => 978-953-307-270-8 [unix_name] =>
bioethics-in-the-21st-century [visible_online] => 1 )
This is my view(better said...poor attempt of a view ). I'm trying to get an alignment based on the index of the array. Like so:
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>
Thank you for your help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
你正在尝试这样做吗?
作为旁注,应避免
语法,因为
short_open_tag
在许多 PHP 安装中被禁用,并且在 PHP 5.4.0 之前需要使用该语法Are you trying to do this?
As a side note,
<?=$var;?>
syntax should be avoided sinceshort_open_tag
is disabled in many PHP installations, and this was required to use that syntax until PHP 5.4.0取决于您如何从数据库中获取结果,它将是这样的:
或者如果您使用的是学说:
您应该阅读教程,其中包含类似的内容:)
http://framework.zend.com/manual/en/zend.db .statement.html
Depends on how You got the result form database it will be something like this:
Or if You're using doctrine:
You should read tutorial, things like that are in it :)
http://framework.zend.com/manual/en/zend.db.statement.html
像这样 ?
Like this ?