如何根据变量显示表? [英] How to show table based on variable?

查看:45
本文介绍了如何根据变量显示表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想根据按钮是否按下
来显示页面上的表格。我是php的新手,所以我确定我犯了一个基本的错误。这就是我想要的。我的想法是$ show_summary

会在每次点击时切换状态,但它总是正确的。

所以我猜这是页面的默认设置负载。可以

有人请指出我哪里出错?


if(isset($ _ POST [''summary''])){

$ show_summary = true;

} else {

$ show_summary = false;

}

< FORM method =" POST" action =" testpage.php">

< INPUT type =" submit"名称= QUOT;总结" value =" Show Summary">

< / FORM>

<?php if($ show_summary == true){?>

< table border =" 1" cellpadding =" 3"

< tr>

< td class =" smallText"对齐= QUOT;中心" width =" 80%"><?php echo" URL";

?>< / td>

< / tr>

< / table>

<?php}?>


杰克

I want to display a table on a page based on whether a button is
pressed or not. I''m new at php so I''m sure I''m making a basic
mistake. Here''s what I am trying. My thought was that $show_summary
would switch states with each click but it is coming up always true.
So I''m guessing that is the default setting when the page loads. Can
someone please point out where I am going wrong?

if(isset($_POST[''summary''])) {
$show_summary = true;
} else {
$show_summary = false;
}

<FORM method="POST" action="testpage.php">
<INPUT type="submit" name="summary" value="Show Summary">
</FORM>

<?php if ($show_summary == true) { ?>
<table border="1" cellpadding="3">
<tr>
<td class="smallText" align="center" width="80%"><?php echo "URL";
?></td>
</tr>
</table>
<?php } ?>

Jack

推荐答案

show_summary

会在每次点击时切换状态,但它总是正确的。

所以我猜这个是页面加载时的默认设置。可以

有人请指出我出错的地方吗?


if(isset(
show_summary
would switch states with each click but it is coming up always true.
So I''m guessing that is the default setting when the page loads. Can
someone please point out where I am going wrong?

if(isset(


_POST [''摘要''])){
_POST[''summary''])) {


show_summary = true;

} else {
show_summary = true;
} else {


这篇关于如何根据变量显示表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆