我需要通过按钮单击将数组从一个页面传递到其他页面。实际上,我在数组中获取数据库的每一列 nw 我想将该数组传递到不同的页面。我使用了会话变量,但它不起作用。
获取这些动态数组的编码 og page2.php
<?php
if (isset($_POST['submit'])) {
$data_t1 = $_POST['t1'];
foreach ($data_t1 as $key => $value) {
$value ;
$_POST['t2'][$key];
$_POST['a1'][$key];
$_POST['username'][$key];
}
$data_t2 = $_POST['t2'];
$data_t3=$_POST['a1'];
$data_t4=$_POST['username'];
}
现在我将这些数组放在数据库中 n 获取它们我需要将这些获取数组传递到下一页
<?php
//database connection
$db = new PDO("mysql:host=localhost;dbname=ems",'root','');
//query
$sql = "INSERT INTO table1 (c0,c1, c2, c3, c4,) VALUES ('',:c1, :c2, :c3, :c4,)
$stmt = $db->prepare($sql);
foreach ($data_t1 as $i => $value) {
$stmt->execute(array(
':c1'=>$data_t1[$i],
':c2'=>$data_t2[$i],
':c3'=>$data_t3[$i],
':c4'=>$data_t4[$i],
<?php
include('config.php');
$sa="select * from table1 where timestamp=now()";
$result=mysql_query($sa) or die(mysql_error());
while($row = mysql_fetch_array($result))
{
$row['c1'];
$row['c2'];
$row['c3'];
$row['c4'];
$m[]=round(($row['c1']/$row['c4']);
$n[]=round(($row['c2']/$row['c4']),2);
$o[]=round(($row['c3']/$row['c4']),2);
$row_count++;
}
在这里我调用 fecth 数组进行显示
<?php
session_start();
$_SESSION['name'] =$r;
$_SESSION['name1'] = $r1;
$_SESSION['name2'] = $r2;
for($i=0;$i<$row_count;$i++)
{ // do the exploding, the imploding, the row echoing for each row//
?>
<?php
echo "<table border='1' align='center'>
<tr>
<th>Inputs</th>
<th>A</th>
<th>B</th>
<th>C</th>
</tr>";
echo "Meas1".($i+1);
echo "<tr>";
$f=implode($m,',');
$r=explode(',',$f);
$f1=implode($n,',');
$r1=explode(',',$f1);
$f2=implode($o,',');
$r2=explode(',',$f2);
display of data
echo "<td>".$r[$i]. "</td>";
echo "<td>".$r1[$i]. "</td>";
echo "<td>".$r2[$i]. "</td>";
}
当我访问这些页面时,page2.php 上的所有编码,r[],r1[],r2[]
即next page
它向page3.php
我显示空数组
page3.php
<?php
session_start();
$r= $_SESSION['name'];
echo $r;
var_dump($r);
print_r($r);
$r1= $_SESSION['name1'];
echo $r1;
print_r($r1);
$r2= $_SESSION['name2'];
echo $r2;
print_r($r2);
?>
请帮忙