【发布时间】:2012-09-25 15:25:14
【问题描述】:
当我点击一个链接时,我正在从数据库中写入我的 $_SESSION 变量。
public function getProjectById($id){
$query="SELECT * FROM projects WHERE id=\"$id\"";
$result=mysql_query($query);
$num=mysql_numrows($result);
while ($row = mysql_fetch_object($result)) {
$_SESSION['projectid'] = $row->id;
$_SESSION['projecttitle'] = $row->title;
$_SESSION['projectinfo'] = $row->info;
$_SESSION['projecttext'] = $row->text;
$_SESSION['projectcategory'] = $row->category;
}
}
现在我的变量被覆盖了,我想在我的 index.php 中显示这些变量,如下所示:
<div id="textContent">
<?php
if(isset($_SESSION['projecttext']) && !empty($_SESSION['projecttext'])) {
echo $_SESSION['projecttext'];
}else {
echo 'No text';
}
?></div>
当然,我的页面不会自动刷新。我该怎么做?
编辑:调用代码:
$(document).on("click", ".sublink", function(){
var subsite = $(this).data('subsite');
var category = $(this).data('category');
var title = $(this).data('title');
var info = category + "/" + title;
var lower = info.toLowerCase();
var nospaces = lower.split(' ').join('');
$('#imageContent').load('php/getImages.php?info='+nospaces);
$('#textContent').load('php/getProjectById.php?id='+subsite);
});
【问题讨论】:
-
“现在我的变量已被覆盖”是什么意思?什么时候发生?
-
我的意思是它被我数据库中的新数据所取代。当我点击我的链接时会发生这种情况。但它不会刷新图形布局。文字不会改变