我想请求帮助重新创建以下代码。我将page1.php中的表单数据传输到page2.php,其中包含来自page1.php的表单数据。场景是每当变量ddList1大于0时,它将执行下面的代码,在html中显示它。否则,当变量设置为0时,它将隐藏html代码的块
<?php
if($_POST["ddList1"] > 0)
echo $_POST["ddList1"];
?>
<table>
<tr>
<td><?php echo $_POST["ddList1"]; ?></td>
<td><?php echo $_POST["ddList1name"]; ?></td>
<td><?php echo $_POST["ddList1desc"]; ?></td>
<td>
<?php
$_ddList1 = $_POST["ddList1"];
switch ($_ddList1) {
case "1":
echo "<button type=\"button\" class=\"btn btn-info ButtonOne1\" onclick=\"openwindow1();\" aria-label=\"Left Align\"><span class=\"glyphicon glyphicon glyphicon-list-alt\" aria-hidden=\"true\"></span></button> ";
break;
case "2":
echo "<button type=\"button\" class=\"btn btn-info ButtonOne1\" onclick=\"openwindow1();\" aria-label=\"Left Align\"><span class=\"glyphicon glyphicon glyphicon-list-alt\" aria-hidden=\"true\"></span></button> ";
echo "<button type=\"button\" class=\"btn btn-info ButtonOne1\" onclick=\"openwindow1();\" aria-label=\"Left Align\"><span class=\"glyphicon glyphicon glyphicon-list-alt\" aria-hidden=\"true\"></span></button> ";
break;
case "3":
echo "<button type=\"button\" class=\"btn btn-info ButtonOne1\" onclick=\"openwindow1();\" aria-label=\"Left Align\"><span class=\"glyphicon glyphicon glyphicon-list-alt\" aria-hidden=\"true\"></span></button> ";
echo "<button type=\"button\" class=\"btn btn-info ButtonOne1\" onclick=\"openwindow1();\" aria-label=\"Left Align\"><span class=\"glyphicon glyphicon glyphicon-list-alt\" aria-hidden=\"true\"></span></button> ";
echo "<button type=\"button\" class=\"btn btn-info ButtonOne1\" onclick=\"openwindow1();\" aria-label=\"Left Align\"><span class=\"glyphicon glyphicon glyphicon-list-alt\" aria-hidden=\"true\"></span></button>";
break;
case "4":
echo "<button type=\"button\" class=\"btn btn-info ButtonOne1\" onclick=\"openwindow1();\" aria-label=\"Left Align\"><span class=\"glyphicon glyphicon glyphicon-list-alt\" aria-hidden=\"true\"></span></button> ";
echo "<button type=\"button\" class=\"btn btn-info ButtonOne1\" onclick=\"openwindow1();\" aria-label=\"Left Align\"><span class=\"glyphicon glyphicon glyphicon-list-alt\" aria-hidden=\"true\"></span></button> ";
echo "<button type=\"button\" class=\"btn btn-info ButtonOne1\" onclick=\"openwindow1();\" aria-label=\"Left Align\"><span class=\"glyphicon glyphicon glyphicon-list-alt\" aria-hidden=\"true\"></span></button> ";
echo "<button type=\"button\" class=\"btn btn-info ButtonOne1\" onclick=\"openwindow1();\" aria-label=\"Left Align\"><span class=\"glyphicon glyphicon glyphicon-list-alt\" aria-hidden=\"true\"></span></button>";
break;
case "5":
echo "<button type=\"button\" class=\"btn btn-info ButtonOne1\" onclick=\"openwindow1();\" aria-label=\"Left Align\"><span class=\"glyphicon glyphicon glyphicon-list-alt\" aria-hidden=\"true\"></span></button> ";
echo "<button type=\"button\" class=\"btn btn-info ButtonOne1\" onclick=\"openwindow1();\" aria-label=\"Left Align\"><span class=\"glyphicon glyphicon glyphicon-list-alt\" aria-hidden=\"true\"></span></button> ";
echo "<button type=\"button\" class=\"btn btn-info ButtonOne1\" onclick=\"openwindow1();\" aria-label=\"Left Align\"><span class=\"glyphicon glyphicon glyphicon-list-alt\" aria-hidden=\"true\"></span></button> ";
echo "<button type=\"button\" class=\"btn btn-info ButtonOne1\" onclick=\"openwindow1();\" aria-label=\"Left Align\"><span class=\"glyphicon glyphicon glyphicon-list-alt\" aria-hidden=\"true\"></span></button> ";
echo "<button type=\"button\" class=\"btn btn-info ButtonOne1\" onclick=\"openwindow1();\" aria-label=\"Left Align\"><span class=\"glyphicon glyphicon glyphicon-list-alt\" aria-hidden=\"true\"></span></button>";
break;
default:
echo "out of range";
}
?>
</td>
</tr>
</table>
答案 0 :(得分:2)
Series.Points
答案 1 :(得分:1)
你的if语句将运行语句echo $ _POST [“ddList1”];因为如果遵循这种格式。
if(expression)
statement;
自“echo $ _POST [”ddList1“];”是以下语句,条件将仅适用于此语句。
您可能想尝试以下格式:
<?php
if(condition):
statement1;
statement2;
...
?>
<h1>HTML code here!<h1>
<?php endif; ?>
祝你好运!
答案 2 :(得分:1)
mr