mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-12 22:38:52 +00:00
[ticket/10737] Improvements over last commit
PHPBB3-10737
This commit is contained in:
parent
dad60045b6
commit
bc67377400
3 changed files with 28 additions and 68 deletions
|
@ -982,37 +982,21 @@ switch ($mode)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'livesearch':
|
case 'livesearch':
|
||||||
$q=request_var('q','');
|
$q=request_var('q', '', true);
|
||||||
$hint="";
|
$hint="";
|
||||||
// Get us some users :D
|
$sql = "SELECT username, user_id
|
||||||
$sql = "SELECT u.user_id
|
FROM " . USERS_TABLE . " u
|
||||||
FROM " . USERS_TABLE . " u
|
WHERE username LIKE '".$q."%' AND u.user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ")";
|
||||||
WHERE u.user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ")";
|
|
||||||
|
|
||||||
$result = $db->sql_query($sql);
|
|
||||||
$user_list = array();
|
|
||||||
while ($row = $db->sql_fetchrow($result))
|
|
||||||
{
|
|
||||||
$user_list[] = (int) $row['user_id'];
|
|
||||||
}
|
|
||||||
$db->sql_freeresult($result);
|
|
||||||
$sql = 'SELECT *
|
|
||||||
FROM ' . USERS_TABLE . '
|
|
||||||
WHERE ' . $db->sql_in_set('user_id', $user_list);
|
|
||||||
$result = $db->sql_query($sql);
|
$result = $db->sql_query($sql);
|
||||||
$i=1;
|
$i=1;
|
||||||
while ($row = $db->sql_fetchrow($result))
|
while ($i<=10 && $row = $db->sql_fetchrow($result))
|
||||||
{ $j=($i%2)+1;
|
{
|
||||||
if(stripos($row['username'],$q)===0)
|
$j=($i%2)+1;
|
||||||
{
|
$hint.="<tr class='bg".$j." row".$j."'><td><a href='" .
|
||||||
$hint.="<tr class='bg".$j." row".$j."'><td><a href='" .
|
$phpbb_root_path."memberlist.$phpEx". "?mode=viewprofile&u=" . $row['user_id'] .
|
||||||
$phpbb_root_path."memberlist.$phpEx". "?mode=viewprofile&u=" . $row['user_id'] .
|
"' target='_blank'>" .
|
||||||
"' target='_blank'>" .
|
$row['username'] . "</a></td></tr>";
|
||||||
$row['username'] . "</a></td></tr>";
|
$i++;
|
||||||
$i++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
$hint.="";
|
|
||||||
}
|
}
|
||||||
echo $hint;
|
echo $hint;
|
||||||
exit();
|
exit();
|
||||||
|
|
|
@ -1,30 +1,18 @@
|
||||||
<script>
|
<script>
|
||||||
function showHint(str)
|
function showHint(str)
|
||||||
{
|
{
|
||||||
if (str.length==0)
|
if (str.length<3)
|
||||||
{
|
{
|
||||||
document.getElementById("livesearch").innerHTML="";
|
document.getElementById("livesearch").innerHTML="";
|
||||||
document.getElementById("livesearch").style.border="0px";
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (window.XMLHttpRequest)
|
|
||||||
{// code for IE7+, Firefox, Chrome, Opera, Safari
|
$.ajax({
|
||||||
xmlhttp=new XMLHttpRequest();
|
url:'{S_LIVE_SEARCH_ACTION}'+"&q="+str,
|
||||||
}
|
success:function(result){
|
||||||
else
|
$("#livesearch").html(result);
|
||||||
{// code for IE6, IE5
|
}
|
||||||
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
|
});
|
||||||
}
|
|
||||||
xmlhttp.onreadystatechange=function()
|
|
||||||
{
|
|
||||||
if (xmlhttp.readyState==4 && xmlhttp.status==200)
|
|
||||||
{
|
|
||||||
document.getElementById("livesearch").innerHTML=xmlhttp.responseText;
|
|
||||||
document.getElementById("livesearch").style.border="0px";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
xmlhttp.open("GET",'{S_LIVE_SEARCH_ACTION}'+"&q="+str,true);
|
|
||||||
xmlhttp.send();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function clearSearch()
|
function clearSearch()
|
||||||
|
|
|
@ -67,30 +67,18 @@
|
||||||
<script>
|
<script>
|
||||||
function showHint(str)
|
function showHint(str)
|
||||||
{
|
{
|
||||||
if (str.length==0)
|
if (str.length<3)
|
||||||
{
|
{
|
||||||
document.getElementById("livesearch").innerHTML="";
|
document.getElementById("livesearch").innerHTML="";
|
||||||
document.getElementById("livesearch").style.border="0px";
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (window.XMLHttpRequest)
|
|
||||||
{// code for IE7+, Firefox, Chrome, Opera, Safari
|
$.ajax({
|
||||||
xmlhttp=new XMLHttpRequest();
|
url:'{S_LIVE_SEARCH_ACTION}'+"&q="+str,
|
||||||
}
|
success:function(result){
|
||||||
else
|
$("#livesearch").html(result);
|
||||||
{// code for IE6, IE5
|
}
|
||||||
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
|
});
|
||||||
}
|
|
||||||
xmlhttp.onreadystatechange=function()
|
|
||||||
{
|
|
||||||
if (xmlhttp.readyState==4 && xmlhttp.status==200)
|
|
||||||
{
|
|
||||||
document.getElementById("livesearch").innerHTML=xmlhttp.responseText;
|
|
||||||
document.getElementById("livesearch").style.border="0px";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
xmlhttp.open("GET",'{S_LIVE_SEARCH_ACTION}'+"&q="+str,true);
|
|
||||||
xmlhttp.send();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function clearSearch()
|
function clearSearch()
|
||||||
|
|
Loading…
Add table
Reference in a new issue