我想通过会话发布$dataHeadArr
值并在下一页中获取。
<?php
if(isset($_POST["search"]))
{ $storename=$_POST["StoreName"];
$dataHeadArr=$db->query("SELECT *FROM `opening_stk`");?>
答案 0 :(得分:0)
您可以在POST或SESSION数组中设置它,然后在下一页上检索它。对于前 -
$_POST['dataHeadArr']=$dataHeadArr;
答案 1 :(得分:0)
存储......
$_SESSION['dataHeadArr'] = 'Whatever';
然后简单地检索..
if(isset($_SESSION['dataHeadArr'])){
echo $_SESSION['dataHeadArr'];
}
确保调用session_start();在每页的顶部。
答案 2 :(得分:0)
打开您发布的页面
<?php
if(isset($_POST["search"])){
session_start();
$storename=$_POST["StoreName"];
$dataHeadArr=$db->query("SELECT * FROM `opening_stk`");
while($row=mysql_fetch_assoc($dataHeadArr)){
$allRows[]=$row;
}
$_SESSION['dataHeadArr']=$allRows;
}
?>
对于要检索变量put的页面
<?php
session_start();
$dataHeadArr=$_SESSION['dataHeadArr'];
//This mysql result been parsed already, so you should be
//able to access values when you loop through it from here
for($i=0;$i<count($dataHeadArr); $i++){
echo "Printing row ".$i."</br>";
foreach($dataHeadArr[$i] as $key=>$item){
//Prints out all value for the row
echo $item[$key]."</br>";
}
echo "</br>";
}
?>