跪求解答,while嵌套if语句问题

心意 2011-10-28 02:19:41
<?php
$radio_buttons = 0;
//读取一个存放地址的表
$addresses_query = tep_db_query("select address_book_id, entry_firstname as firstname, entry_lastname as lastname, entry_company as company, entry_street_address as street_address, entry_suburb as suburb, entry_city as city, entry_postcode as postcode, entry_state as state, entry_zone_id as zone_id, entry_country_id as country_id from " . TABLE_ADDRESS_BOOK . " where customers_id = '" . (int)$customer_id . "'");
while ($addresses = tep_db_fetch_array($addresses_query)) { //tep_db_fetch_array() 调用了mysql_fetch_array()函数
//判断 如果表的ID等于5 就打印“显示”否则“隐藏”
if($addresses['address_book_id'] == 5){
echo '显示'
?>
<table style="display:none;" id="electAddress" name="electAddress" border="0" width="100%" cellspacing="0" cellpadding="2">
<?php
}
else {

echo '隐藏'


<?php
}

}
?>
</table>



为什么结果是 隐藏 隐藏 隐藏 隐藏 显示
...全文
270 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
心意 2011-10-28
  • 打赏
  • 举报
回复
还有就是 5 之后的全部隐藏了 5 之前的就没隐藏掉 这是怎么回事呢
心意 2011-10-28
  • 打赏
  • 举报
回复
还有其他的办法没
心意 2011-10-28
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 tottyandbaty 的回复:]
看不明白,你还不如这样写:


PHP code


$addresses_query = tep_db_query("select * from " . TABLE_ADDRESS_BOOK . " where customers_id ='{$customer_id}' and ");
while ($addresses = tep_db_fetch_array($address……
[/Quote]
呵呵 这也是个办法
ohmygirl 2011-10-28
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 laihui19891004 的回复:]

引用 5 楼 ohmygirl 的回复:
引用 2 楼 laihui19891004 的回复:

我想要的是 只显示 “显示”隐藏不显示出来


把else那块去掉就行了.



我代码简化了 还有个按钮 可以把隐藏的显示的来的
[/Quote]

点击按钮控制显示隐藏,请用js
心意 2011-10-28
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 ohmygirl 的回复:]
引用 2 楼 laihui19891004 的回复:

我想要的是 只显示 “显示”隐藏不显示出来


把else那块去掉就行了.
[/Quote]


我代码简化了 还有个按钮 可以把隐藏的显示的来的
ohmygirl 2011-10-28
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 laihui19891004 的回复:]

我想要的是 只显示 “显示”隐藏不显示出来
[/Quote]

把else那块去掉就行了.
tottyandbaty 2011-10-28
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 tottyandbaty 的回复:]

看不明白,你还不如这样写:

PHP code

$addresses_query = tep_db_query("select * from " . TABLE_ADDRESS_BOOK . " where customers_id ='{$customer_id}' and ");
while ($addresses = tep_db_fetch_array($addresses_qu……
[/Quote]

写的有些错误。。。自己改
tottyandbaty 2011-10-28
  • 打赏
  • 举报
回复
看不明白,你还不如这样写:


$addresses_query = tep_db_query("select * from " . TABLE_ADDRESS_BOOK . " where customers_id ='{$customer_id}' and ");
while ($addresses = tep_db_fetch_array($addresses_query))
{
if($addresses['address_book_id'] == 5)
{
$display="block"
}
else
{
$display="none"
}

echo "<table style=\"display:{$display};\"......";//

}
心意 2011-10-28
  • 打赏
  • 举报
回复
我想要的是 只显示 “显示”隐藏不显示出来
ohmygirl 2011-10-28
  • 打赏
  • 举报
回复
应该是什么结果?

21,886

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧