Morning Bakers
I have the following case: In my application I have a search engine,
which you enter your email or name, it searches for registered users
to these criteria. The problem is that instead of a text input area, I
want to make a selection with SELECT, so the user does not have to
type anything, moreover wanted to have the same form a SELECT list of
options that will be added and show Users with these criteria.
I've tried everything, but unfortunately not able to make it work. Who
can help thanks.
The application works like this: The search criteria are in VIEW
Busca_a, and Pequisar pressing the button, this button calls the
function search () in controller and VIEW search.
The function in my CONTROLLER
function usuario_busca() {
$this-set('meuPerfil', 1);
if(!empty($this-data['tipo']) AND
!empty($this-data['valor'])) {
switch($this-data['tipo']) {
case 'nome':
$dados =
$this-Usuario-find('all',
array('conditions'=array('or'=array(
'sexualidade_usuario'=$this-data['valor'],
'nome_usuario
LIKE'='%'.$this-data['valor'].'%',
'nascimento_usuario
LIKE'='%'.$this-data['valor'],
'email_usuario'=$this-data['valor'] ,
'descricao_usuario'=$this-data['valor'],
'culinaria_usuario'=$this-data['valor'],
'altura_usuario'=$this-data['valor'],
'relacionamento_usuario'=$this-data['valor'],
'paixao_usuario'=$this-data['valor'])),
'order'=array('nome_usuario
ASC'), 'limit'=200));
break;
default: break;
}
if(isset($dados) AND !empty($dados))
$this-set('dados', $dados);
$busca = array('valor'= $this-data['valor']);
$this-set('busca', $busca);
}
else $this-redirect($this-site['url']['site'] . 'usuario/rede/
perfil');
}
THE VIEWs
VIEW BUSCA_A
form action=?php echo $site['url']['site'] ?usuario/rede/busca
method=post class=form busca
label for=nome_contatoQual é o numero de sua
escolha:/label
input type=text id=nome_contato name=data[valor]
/
input type=hidden name=data[tipo] value=nome /
button class=botao_1 botao_1_1 type=submit
title=PesquisarPesquisar/button
button class=botao_1 botao_1_1 type=reset
title=Limpar BuscaLimpar Busca/button
/form/ul/div
USUARIO BUSCA()
?php
$this-pageTitle = 'REDE: Resultado da busca para ' . $busca['valor'];
echo $this-element('barralateral');
?
div id=pag-rede-busca class=conteudo rede
?php $msgAlerta = $session-flash(); if(!empty($msgAlerta)) echo
'div class=alerta_1 alerta_1_1' . $msgAlerta . '/div'; ?
div class=box_e
?php
$img = (!empty($usuarioON['imagem_usuario'])) ?
'upload/usuarios/
escala/' . $usuarioON['imagem_usuario'] : 'usuario.jpg';
echo 'img src=' . $site['url']['prefix'] . 'img/' . $img . '
alt=' . $usuarioON['nome_usuario'] . ' title=' .
$usuarioON['nome_usuario'] . ' width=175 /';
echo $this-element('lateralrede');
?
/div
div class=box_d
h2Resultados da busca para: span class=db?php echo
$busca['valor'] ?/span/h2
div class=conteudo
?php if(isset($dados) AND !empty($dados)): ?
ul class=produtos
?php
foreach($dados as $item):
$item = $item['Usuario'];
$nomePart = explode(' ',
$item['nome_usuario']);
$nome = $nomePart[0];
if(isset($nomePart[1]) AND
!empty($nomePart[1])) $nome .= ' ' .
$nomePart[1];
?