显示时数据位置的问题
我有 2 个名为“authors”和“authors”的表。图书。作者必须有徽标。我必须显示作者姓名、徽标,然后显示该作者的所有书籍等等。 books 表包含一个字段(show_logo),如果该作者的所有书籍的 show_logo 为 0,则徽标将显示在开头(即作者姓名之后),否则徽标将显示在该书之后(show_logo 1)。如果任何一本书的 show_logo 为 1,那么它将在该书之后正确显示,否则不会..正在使用下面的代码
<?php
if ($author) {
foreach ($$author as $key => $val) {
?>
<tr style="background-color: #58353C;"><?php
if ($val['$author_image']) {
?>
<td><img src="<?= base_url(); ?>uploads/<?= $author; ?>" style="width: 90px;height: 90px;"/></td>
<td style="color: #F5E78F;" colspan="4"><b><?= $val['$author_name']; ?></td>
<?
foreach ($val['books'] as $key => $val1) {
?>
<tr style="background-color:<?= $color ?>">
<?php
if ($val1['author_image']) {
?>
<td style="padding-left: 20px;color: black; "><img src="<?= base_url(); ?>uploads/<?= $val1['author_image']; ?>" style="width: 75px;height: 75px;" /></td>
<?php } ?>
<td style="color: black;"><?= $val1['author_title']; ?></td>
<td width="150px" style="text-align: left;color: black;"><a class="more" style="color: black;font-size: 11px;" href="<?= site_url('author/author_view/' . $key); ?>" rel="facebox">More Details..</a></td>
<?
if ($val1['show_logo'] == '1') {
if ($val['author_logo']) {
?></tr>
<tr style="background-color:<?= $color; ?>" on>
<td colspan="5"><img src="<?= base_url(); ?>uploads/<?= $val['author_logo']; ?>" style="width: 998px;height: 175px;" /></td>
</tr>
<?
}
} else {
?></tr> <?
}
$counter++;
}
}
}
}
?>
I have 2 tables named authors & books. Authors must have a logo. I have to display this like author name , logo,then all the books of that author and so on. books table contain a field (show_logo), if the show_logo is 0 for all the books of that author then the logo will display at the begining (ie after author name) else logo will display after that book(show_logo 1). If the show_logo is 1 for any book then it will display properly after that book, Otherwise won't..am using the code below
<?php
if ($author) {
foreach ($author as $key => $val) {
?>
<tr style="background-color: #58353C;"><?php
if ($val['$author_image']) {
?>
<td><img src="<?= base_url(); ?>uploads/<?= $author; ?>" style="width: 90px;height: 90px;"/></td>
<td style="color: #F5E78F;" colspan="4"><b><?= $val['$author_name']; ?></td>
<?
foreach ($val['books'] as $key => $val1) {
?>
<tr style="background-color:<?= $color ?>">
<?php
if ($val1['author_image']) {
?>
<td style="padding-left: 20px;color: black; "><img src="<?= base_url(); ?>uploads/<?= $val1['author_image']; ?>" style="width: 75px;height: 75px;" /></td>
<?php } ?>
<td style="color: black;"><?= $val1['author_title']; ?></td>
<td width="150px" style="text-align: left;color: black;"><a class="more" style="color: black;font-size: 11px;" href="<?= site_url('author/author_view/' . $key); ?>" rel="facebox">More Details..</a></td>
<?
if ($val1['show_logo'] == '1') {
if ($val['author_logo']) {
?></tr>
<tr style="background-color:<?= $color; ?>" on>
<td colspan="5"><img src="<?= base_url(); ?>uploads/<?= $val['author_logo']; ?>" style="width: 998px;height: 175px;" /></td>
</tr>
<?
}
} else {
?></tr> <?
}
$counter++;
}
}
}
}
?>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为什么不使用 CodeIgniter 2.x 默认包中包含的 HTML Table Library ?只需预先格式化数组即可达到正确的结构。
why don't you use the HTML Table Library that CodeIgniter 2.x includes in default package? Just pre-format you arrays to reach proper structure.