我有一个php / mysql站点工作,它基本上跟踪应该在确定的时间运行的任务。 我被要求描述用户,所以没有人看到对方的项目。 到目前为止,这么好,几乎完成了,一般来说,通过创建角色表来解决它,用户限制在查询条件中。
我遇到了一个问题我不认为会发生这种情况。在我的搜索/过滤器表单中,我有一个使用数据库连接的jquery autocomplete textarea,因此用户可以按任务名称进行搜索。 现在,当我(仅)更改获取任务名称的查询时,自动完成功能不再起作用了!
查询是好的,它返回相同的结果和前一个,只有少数结果,因为新条件,没有其他变化!
工作自动完成:
HTML:
if (isset($Ptask)):
<input title="Task" size="45" type="text" value="'.$Ptask.'" id="task" name="task" >
endif;
的javascript:
$( "#task" ).autocomplete({
source: "includes/search.php",
minLength: 2,
select: function( event, ui ) {
log( ui.item ? "" + ui.item.value :
"Nothing selected, input was " + this.value );}
});
PHP:
<?php
include ('../connect-db.php');
$q = trim(strip_tags($_GET['term']));
$qstring = "SELECT name as value FROM TASKS WHERE name LIKE '%".$q."%' AND public='1' AND active='1'";
$result = mysql_query($qstring);
while ($row = mysql_fetch_array($result,MYSQL_ASSOC))
{
$row['value'] = iconv('ISO-8859-1', 'UTF-8', $row['value']);
$row_set[] = $row;
}
echo json_encode($row_set);
?>
不使用这个php:
<?php
include ('../connect-db.php');
include ('session_check.php');
$q = trim(strip_tags($_GET['term']));
$qstring = "SELECT t.name as value
FROM CO_SERV AS s, CO_APP AS ap, CO_USERS AS u, CO_GROUPS AS g, CO_GROUP_ROLES AS gr, TASKS AS t
WHERE name LIKE '%".$q."%'
AND g.ID_G = u.ID_G
AND s.ID = gr.ID_S
AND g.ID_G = gr.ID_G
AND ap.ID_AP = gr.ID_AP
AND u.ID_U = '3' //example id user to test it will be a post
AND t.servico = s.ID
AND ap.ID_AP = t.app
AND t.public = '1'
AND t.ative = '1'
AND gr.ative = '1'";
$result = mysql_query($qstring);
while ($row = mysql_fetch_array($result,MYSQL_ASSOC))
{
$row['value'] = iconv('ISO-8859-1', 'UTF-8', $row['value']);
$row_set[] = $row;
}
echo json_encode($row_set);
?>
此查询很好并且返回与另一个相同,唯一的区别是它仅限于用户权限 看不出有什么问题。
赞赏任何形式的帮助:)
祝你好运 贡萨洛