Ver Mensaje Individual
  #1 (permalink)  
Antiguo 01/05/2013, 09:03
Avatar de ChatDelMundo
ChatDelMundo
 
Fecha de Ingreso: abril-2013
Mensajes: 98
Antigüedad: 11 años
Puntos: 1
Añadir boton al buscador



Tengo este buscador pero al pasar el cursor con el mouse no sirve, solo funciona dando Enter
Código PHP:
function index() {
        
c('
        <form action="'
.url('search/listing').'" method="post">
        <p>
        <label>title</label> <input type="text" name="title" />
        </p>
        <p>
        <input type="submit" class="button" value="'
.t('Submit').'" />
        </p>
        </form>
        '
);
    }
    
    function 
listing() {
        global 
$offset$num_per_page$page;
        
$title trim($_POST['title']);
        
$display_title stripslashes(trim($_POST['title']));
        
c('Searching <strong>'.h($title).'</strong><br />');
        if (
strlen($title) < 3) {
            
sys_back(t('Keyword is too short'));
        }
        else {
            
$hash substr(md5($title),0,12);
            if (
$c get_cache($hash)) {
                
header("location:".url('search/result/'.$hash));
                exit;
            }
            else {
                
$c '<h1>'.h($display_title).'</h1>';
                
$res sql_query("select * from ".tb()."accounts where username like '%{$title}%' or fullname like '%{$title}%'  order by lastlogin DESC limit 10");
                while (
$user sql_fetch_array($res)) {
                    
$users .= '<li>'.url('u/'.$user['username'],$user['username']).'<br />'.avatar($user).'<br />'.h($user['fullname']).'</li>';
                }
                if (
strlen($users)) {
                    
$c .= '<h2>'.t('Members').'</h2>';
                    
$c .= '<ul class="small_avatars">'.$users.'</ul>';
                }
                
$c .= '<h2>'.t('Stories').'</h2>
                    <p>Searching for <strong>"'
.h($title).'"</strong></p>';
                
$res sql_query("select s.*,u.username from `".tb()."stories` as s left join ".tb()."accounts as u on u.id=s.uid where s.title LIKE '%$title%' ORDER BY s.id DESC LIMIT 20");
                if (!
sql_counts($res)) {
                    
$c .= '<p>no story matched</p>';
                }
                else {
                    
$c .= 'Stories:<br /><ul class="post">';
                    while(
$story sql_fetch_array($res)) {
                        
$c .= '<li>
                        ['
.url($story['app'],app_name($story['app'])).'] 
                        <a href="'
.url($story['app'].'/viewstory/'.$story['id']).'">'.str_replace($title,'<strong>'.h($title).'</strong>',htmlspecialchars($story['title'])).'</a><br />'.get_date($story['created']).', by '.url('u/'.$story['username'],$story['username']).'
                        </li>'
;
                    }
                    
$c .= '</ul>';
                }
                
set_cache($hash$c48);
                
header("location:".url('search/result/'.$hash));
                exit;
            }
        }
    }

    function 
result($hash) {
        
set_title('Search result');
        
c(get_cache($hash).get_gvar('ad_block_search'));
    }
    

__________________
chatdelmundo.es