Php 在不同页面上显示复选框输出
如何在不同的php页面上显示我的输出我这里有我的代码,在选中复选框并单击提交按钮后,我希望输出显示在另一个页面上,但当前我的代码仅在同一页面上显示输出,非常感谢您的帮助Php 在不同页面上显示复选框输出,php,checkbox,get,Php,Checkbox,Get,如何在不同的php页面上显示我的输出我这里有我的代码,在选中复选框并单击提交按钮后,我希望输出显示在另一个页面上,但当前我的代码仅在同一页面上显示输出,非常感谢您的帮助 <?php $connect=mysqli_connect("localhost","root","","test"); $sql = "SELECT * FROM icheck "; $result = mysqli_query($connect, $sql); //$row = mysqli_fetch_arr
<?php
$connect=mysqli_connect("localhost","root","","test");
$sql = "SELECT * FROM icheck ";
$result = mysqli_query($connect, $sql);
//$row = mysqli_fetch_array($result);
?>
//MY FIRST PAGE
<form method="POST">
<table>
<thead>
<tr>
<th>ID</th>
<th>Name</th>
<th>Price</th>
<th>Check</th>
</tr>
</thead>
<?php
if(mysqli_num_rows($result)>0){
$i=1;
while($row=mysqli_fetch_array($result))
{
echo'<tr>
<td>'.$row['id'].'</td>
<td>'.$row['name'].'</td>
<td>'.$row['price'].'</td>
<td><input type="checkbox" name="check[]" value='.$row['id'].'></td>
';
$i++;
}
}
?>
</table>
<input type="submit" name="submit" Value="Submit"/>
</form>
//OUTPUT TO BE DISPLAYED ON OTHER PAGE or 2nd PAGE
<?php
if(isset($_POST['submit'])){
if(!empty($_POST['check'])) {
// Counting number of checked checkboxes.
$checked_count = count($_POST['check']);
echo "You have selected following ".$checked_count." option(s): <br/>";
if(isset($_POST['check'])){
$sum=0;
foreach($_POST['check'] as $selected) {
$ah="SELECT * FROM icheckWHERE id=".$selected;
$rowz = mysqli_query($connect, $ah);
$row=mysqli_fetch_array($rowz);
echo $row['name']."</br>";
$test=$row['price'];
$sum+=(int)$test;
}
echo "Jay Total na ket: ".$sum;
}
}
else{
echo "<b>Please Select Atleast One Option.</b>";
}
}
?>
//我的第一页
身份证件
名称
价格
检查
//要显示在其他页面或第2页上的输出
首先,将此$\u POST['check']
。这是你的代码将工作的数组。通过vardump变量,您可以找到您的解决方案
您可以与我共享您的vardump结果。第一页中的表单不包含表单操作,因此您必须将表单操作放到第二页,然后才能从第二页捕获发布的数据 //我的第一页
<form method="POST" action="mysecondpage.php">
<table>
<thead>
<tr>
<th>ID</th>
<th>Name</th>
<th>Price</th>
<th>Check</th>
</tr>
</thead>
<?php
if(mysqli_num_rows($result)>0){
$i=1;
while($row=mysqli_fetch_array($result))
{
echo'<tr>
<td>'.$row['id'].'</td>
<td>'.$row['name'].'</td>
<td>'.$row['price'].'</td>
<td><input type="checkbox" name="check[]" value='.$row['id'].'></td>
';
$i++;
}
}
?>
</table>
<input type="submit" name="submit" Value="Submit"/>
</form>
身份证件
名称
价格
检查
hmm我看到imma在处理这件事