如何在php中将数组记录从进程页面传递到索引页面?
How to pass array records from process page to index page in php?
我能够在我的进程页面中显示数组记录,现在我必须传递索引 page.In 数组中的记录,该数组有超过 10 条记录。
一旦该记录将显示在索引上之后,我想在甜蜜警报弹出窗口中显示所有记录。
我正在实现什么...我在甜蜜警报中输入名字,fname 将重定向进程页面并检查 fname 是否可用(如果可用)以及有多少用户可用,所有用户都将重定向到索引页。
我能够检索进程页面中的所有记录,但我必须重定向索引页面上的所有记录。
Getting error:Undefined variable: _SESSION and Invalid argument supplied for foreach()
你愿意帮我吗?
Process.php
$array_record=array();
$array_record['idsa']=$row["Id"];
$array_record['Fname']=$row["First_name"];
$array_record['Lname']=$row["Last_name"];
$_SESSION['arr']=$array_record;
// I tried below echo it display record on process page.
/*
$session=$_SESSION['arr'];
foreach($session as $val)
{
echo $val.'<br>';
}
*/
header('Location: index.php?search=1');
索引
if(!empty($_GET['search'])):
$session=$_SESSION['arr'];
foreach($session as $val)
{
echo $val.'<br>';
}
echo "<script>
setTimeout(function() {
swal({
title: 'You details !',
text: '$val',
type: 'info',
closeOnCancel: true,
html:true
}, function() {
window.location = 'index.php';
});
}, 1000);
</script>";
endif;?>
我不想暗示此方法是执行此操作的最佳方法,但它应该有助于解决您可能遇到的一些问题。
header('Location: startEntry.php?data=' . base64_encode([$row["Id"],$row["First_name"],$row["Last_name"]]));
我认为这里更大的问题是你说你通过了:
more than 10 records
无论您使用何种方法,在某些时候您可能会开始达到 URL 长度限制。
为了获取从process.php到index.php的所有数组记录,请在SESSION中设置该数组并获取index.php中的会话记录。
index.php
<?php
//Submitting form here => action ="process.php"
?>
process.php
<?php
//get the records from DB and set the values in session
// Redirect to index.php
session_start();
$_SESSION['arr'] = $row; // $row is the array from Database
header("Location:index.php");
exit;
?>
index.php
<?php
//Use the values in session
//Unset after using
session_start();
if($_SESSION['arr']){
$session=$_SESSION['arr'];
foreach($session as $val)
{
echo "<pre>";
print_r($val);
echo "</pre>";
}
//you can display the array using print_r($_SESSION).
}
?>
我能够在我的进程页面中显示数组记录,现在我必须传递索引 page.In 数组中的记录,该数组有超过 10 条记录。 一旦该记录将显示在索引上之后,我想在甜蜜警报弹出窗口中显示所有记录。
我正在实现什么...我在甜蜜警报中输入名字,fname 将重定向进程页面并检查 fname 是否可用(如果可用)以及有多少用户可用,所有用户都将重定向到索引页。 我能够检索进程页面中的所有记录,但我必须重定向索引页面上的所有记录。
Getting error:Undefined variable: _SESSION and Invalid argument supplied for foreach()
你愿意帮我吗?
Process.php
$array_record=array();
$array_record['idsa']=$row["Id"];
$array_record['Fname']=$row["First_name"];
$array_record['Lname']=$row["Last_name"];
$_SESSION['arr']=$array_record;
// I tried below echo it display record on process page.
/*
$session=$_SESSION['arr'];
foreach($session as $val)
{
echo $val.'<br>';
}
*/
header('Location: index.php?search=1');
索引
if(!empty($_GET['search'])):
$session=$_SESSION['arr'];
foreach($session as $val)
{
echo $val.'<br>';
}
echo "<script>
setTimeout(function() {
swal({
title: 'You details !',
text: '$val',
type: 'info',
closeOnCancel: true,
html:true
}, function() {
window.location = 'index.php';
});
}, 1000);
</script>";
endif;?>
我不想暗示此方法是执行此操作的最佳方法,但它应该有助于解决您可能遇到的一些问题。
header('Location: startEntry.php?data=' . base64_encode([$row["Id"],$row["First_name"],$row["Last_name"]]));
我认为这里更大的问题是你说你通过了:
more than 10 records
无论您使用何种方法,在某些时候您可能会开始达到 URL 长度限制。
为了获取从process.php到index.php的所有数组记录,请在SESSION中设置该数组并获取index.php中的会话记录。
index.php
<?php
//Submitting form here => action ="process.php"
?>
process.php
<?php
//get the records from DB and set the values in session
// Redirect to index.php
session_start();
$_SESSION['arr'] = $row; // $row is the array from Database
header("Location:index.php");
exit;
?>
index.php
<?php
//Use the values in session
//Unset after using
session_start();
if($_SESSION['arr']){
$session=$_SESSION['arr'];
foreach($session as $val)
{
echo "<pre>";
print_r($val);
echo "</pre>";
}
//you can display the array using print_r($_SESSION).
}
?>