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_contato">Qual é 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="Pesquisar">Pesquisar</button>

                <button class="botao_1 botao_1_1" type="reset"
title="Limpar Busca">Limpar 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">
                <h2>Resultados 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];
                                ?>
                                <li>
                                        <h2><?php echo '<a href="' . 
$site['url']['site'] . 'usuario/rede/
perfil/' . $item['id_usuario'] . '" title="' . $item['nome_usuario'] .
'">' . $nome . '</a>'; ?></h2>
                                        <?php echo '<a href="' . 
$site['url']['site'] . 'usuario/rede/
perfil/' . $item['id_usuario'] . '" title="' . $item['nome_usuario'] .
'"><img src="' . $site['url']['prefix'] . 'img/'; echo (!
empty($item['imagem_usuario'])) ? 'upload/usuarios/100x100/' .
$item['imagem_usuario'] : 'usuario.jpg'; echo '" alt="' .
$item['nome_usuario'] . '" height="100" width="100" /></a>'; ?>
                                </li>
                                <?php endforeach; ?>
                        </ul>
                        <?php
                        else: echo '<p>Nenhum resultado para sua busca.</p>';
                        endif;
                        ?>
                </div>
        </div>
</div>

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to