gpt4 book ai didi

php - 如何获取 php session 变量并在 ssp 的 where 子句中使用它来获取带有数据表的单个 ligne 记录

转载 作者:行者123 更新时间:2023-11-30 23:44:55 26 4
gpt4 key购买 nike

我花了几个小时搜索过滤表的解决方案,并只显示列等于 session 变量值的 ligne recordes,为此我尝试这样做:

i called only one variable session into the server-response.php on head of file : require_once("./_inc/config.php") and i have stocked this session variable to a second variablea as next: $CodeApogee = $_SESSION["code_apogee"]; and this variable i used it as condition in the $sWhere clause as next :

       /* 
* Script: DataTables server-side script for PHP and MySQL
* Copyright: 2012 - John Becker, Beckersoft, Inc.
* Filtering
* NOTE this does not match the built-in DataTables filtering which does it
* word by word on any field. It's possible to do here, but concerned about efficiency
* on very large tables, and MySQL's regex functionality is very limited
*/
$CodeApogee = $_SESSION['code_apogee']; //changes

$sWhere = "notes.code_apogee=".$CodeApogee." ";
if ( isset($_GET['sSearch']) && $_GET['sSearch'] != "" ) {
$sWhere = "WHERE (notes.code_apogee=".$CodeApogee.")"; //changes
for ( $i=0 ; $i<count($columns) ; $i++ ) {
if ( isset($_GET['bSearchable_'.$i]) && $_GET['bSearchable_'.$i] == "true" ) {
$sWhere .= "`".$columns[$i]."` LIKE :search OR ";
}
}
$sWhere = substr_replace( $sWhere, "", -3 );
$sWhere .= ')';
}

<强>_我的 data.php 文件看起来像:_

$(document).ready(function() {
$('#note').dataTable( {
"aProcessing": true,
"aServerSide": true,
"ordering": false,
"searching": true,
"paging": true,
responsive: true,
"ajax": {
url: "server-response.php",
type: 'POST'
}
});
});
</script>
</head>
<body class="note">
<table id="note" class="display responsive table table-striped table-hover dt-responsive" cellspacing="0" width="100%">
<thead>
<tr>
<th class="all" >Code Apogee</th>
<th class="min-phone-l" >Nom</th>
<th class="min-phone-l">Prenom</th>

数据表样式也不会像我配置的那样运行。

Retrieve Session from php and use in DataTable as query variable
请帮助我,我已经阅读了这篇文章,但我不知道该怎么做,

这是 Firebug 屏幕截图,一条记录已被过滤掉,但表中没有数据。 enter image description here

最佳答案

首先,请确保您在两个页面中都使用了 session_start(),从您在 session 中设置值的位置到您在此 session 变量中使用的位置。

其次,改变这个

$CodeApogee = $_SESSION['code_apogee'];
to
$CodeApogee = "'".$_SESSION['code_apogee']. "'";

关于php - 如何获取 php session 变量并在 ssp 的 where 子句中使用它来获取带有数据表的单个 ligne 记录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44118565/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com