将mysql结果集php会话传递给其他页面。 [英] pass mysql resultset php session veriable to other page.

查看:60
本文介绍了将mysql结果集php会话传递给其他页面。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello Friends。

我正在做我的学术项目。

我想在page1.php上的会话变量中获取表值并将其传递给page2.php。但是我收到了一个警告:





警告:main():无法在C:\ xampp \中获取mysqli_result第17行的htdocs \ AirTicket \ booking.php

;



我的page1.php代码:



session_start();

$ _SESSION ['res'];

?>

< ; html>

< body>



$ con = mysqli_connect(localhost,user,**** ,****);

$ query =select * from ****;

$ _SESSION ['res'] = mysqli_query($ con ,$ query);

?>



Page2.php

< / body>

< / html>





< br $>


page2.php代码:



< html>

<头>

< / head>

< body>

session_start();

echo $ _SESSION [' res'];



foreach($ _SESSION ['res']为$ row)

{

echoEmpId:;

echo $ row [EmpId];



echoSalary;

echo $ row [薪水];

打印(
);

}



?>

< / body>

< / html>





在page2.php上执行后,它显示:

警告:main():无法在C:\ xampp \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\第17行的booking.php

;

Hello Friends.
I am doing my academic project.
I want to fetch table values in a session variable on page1.php and pass it to page2.php. but i got a warning :


"Warning: main(): Couldn't fetch mysqli_result in C:\xampp\htdocs\AirTicket\booking.php on line 17
";

my page1.php code:

session_start();
$_SESSION['res'];
?>
<html>
<body>

$con = mysqli_connect("localhost", "user", "****", "****");
$query = "select * from ****";
$_SESSION['res'] = mysqli_query($con, $query);
?>

Page2.php
</body>
</html>




page2.php Code:

<html>
<head>
</head>
<body>
session_start();
echo $_SESSION['res'];

foreach ($_SESSION['res'] as $row)
{
echo "EmpId: ";
echo $row["EmpId"];

echo "Salary";
echo $row["Salary"];
print("
");
}

?>
</body>
</html>


After execute it on page2.php it shows:
"Warning: main(): Couldn't fetch mysqli_result in C:\xampp\htdocs\AirTicket\booking.php on line 17
";

推荐答案

_SESSION ['res'];

?> ;

< html>

< body>


_SESSION['res'];
?>
<html>
<body>


con = mysqli_connect(localhost,user,****,*** *);
con = mysqli_connect("localhost", "user", "****", "****");


query =select * from ****;
query = "select * from ****";


这篇关于将mysql结果集php会话传递给其他页面。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆