Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何将MySQLi查询的结果从一个PHP页面传递到另一个PHP页面?_Php_Mysql - Fatal编程技术网

如何将MySQLi查询的结果从一个PHP页面传递到另一个PHP页面?

如何将MySQLi查询的结果从一个PHP页面传递到另一个PHP页面?,php,mysql,Php,Mysql,我有Page1.php包含各种函数。存在包含MySQLi查询结果的变量$response。 我还有另一个页面Page2.php,它可以以非常格式化的方式显示SQL查询的结果。 如何将,$response从Page1.php传递到Page2.php 我试着跟着 第1页: session_start(); $_SESSION['message'] = $response; header("Location:Page2.php"); die(); session_start();

我有
Page1.php
包含各种函数。存在包含MySQLi查询结果的变量
$response

我还有另一个页面
Page2.php
,它可以以非常格式化的方式显示SQL查询的结果。
如何将,
$response
Page1.php
传递到
Page2.php

我试着跟着

第1页:

session_start();  
$_SESSION['message'] = $response;  
header("Location:Page2.php");  
die();
 session_start();  
    $response = $_SESSION['message']; 
第2页:

session_start();  
$_SESSION['message'] = $response;  
header("Location:Page2.php");  
die();
 session_start();  
    $response = $_SESSION['message']; 
但是,它不起作用(

也欢迎使用任何其他方法将此结果从一个页面传递到另一个页面。

请遵循
Page1.php中的clean方法:

/* seek to row no. 1 */
$response->data_seek(0);

/* fetch row */
$data = $response->fetch_row();

$_SESSION['message'] = $data;

session_write_close();

header("Location:Page2.php");

die();
Page2.php

session_start(); 

$response = $_SESSION['message'];

希望这有帮助。

请遵循
Page1.php中的清洁方法:

/* seek to row no. 1 */
$response->data_seek(0);

/* fetch row */
$data = $response->fetch_row();

$_SESSION['message'] = $data;

session_write_close();

header("Location:Page2.php");

die();
Page2.php

session_start(); 

$response = $_SESSION['message'];

希望这有帮助。

为什么不在第2页中包括第1页?这样你就可以直接访问它的变量了。
打印($_会话)时,你在第2页中得到了什么吗?
在正常情况下,这会起作用,你检查了输出(echo$response;)?当你执行
变量转储($response);
?AG21是的,打印($\u SESSION)向我显示:Array([message]=>mysqli\u result对象),但当我尝试使用该对象时,如:
$response->data\u seek(0);
它会显示:警告:mysqli\u result::data\u seek():无法获取mysqli_结果为什么在第2页中不包含第1页?这样您就可以直接访问它的变量了。
print_r($_SESSION);
在正常情况下这会起作用,您是否检查了输出(echo$response;)?当您执行
var_dump($response);
?AG21是的,print_r($\u SESSION)向我显示:Array([message]=>mysqli\u result对象),但当我尝试使用该对象时,如:
$response->data\u seek(0);
它会显示:警告:mysqli\u result::data\u seek():无法获取mysqli\u结果