Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 31st, 2012  |  syntax: None  |  size: 6.89 KB  |  hits: 15  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. ComboBox NO sql query return result
  2. <!-- BUSCA ARTISTAS
  3.  -->
  4. <!DOCTYPE html>
  5. <?php
  6. session_start();
  7. include_once 'pessoa/pessoa.php';
  8. include_once 'pessoa/artista.php';
  9. include_once 'pessoa/pessoafisica.php';
  10. include_once 'pessoa/endereco.php';
  11. include_once 'pessoa/email.php';
  12. include_once 'pessoa/telefone.php';
  13. include_once 'banco/banco.php';
  14. include_once 'pessoa/especialidade.php';
  15.  
  16. ?>
  17. <html xmlns="http://www.w3.org/1999/xhtml">
  18.     <head>
  19.         <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  20.         <title>Busca</title>
  21.         <style type="text/css" media="all">
  22.  
  23.             table {
  24.                 width:800px;
  25.                 border-collapse: collapse;
  26.                 border: 2px solid #999;
  27.                 margin:0 auto;
  28.                 font-size: small;
  29.             }
  30.             caption {
  31.                 text-align: right;
  32.                 margin-bottom: 0.8em;
  33.                 border-bottom: 1px solid #333;
  34.                 padding-right: 0.1em;
  35.             }
  36.             thead tr th {
  37.                 text-align:center;
  38.                 border-bottom: 2px solid #999;
  39.                 border-left: 1px solid #999;
  40.             }
  41.             tr td, tr th {
  42.                 padding: 2px 1px;
  43.                 text-align:left;
  44.                 font-size: 1em;
  45.                 border: 1px dotted #333;
  46.             }
  47.             tfoot tr td {
  48.                 text-align:center;
  49.                 border-top: 2px solid #999;
  50.             }
  51.             /* CSS para efeitos jQuery */
  52.             .impar {background:#add6ef;}
  53.             .par {background:#d6e2e5;}
  54.             /* Fim CSS para efeitos jQuery */
  55.         </style>
  56.         <link rel="stylesheet" type="text/css" href="estiloformulario.css" />
  57.         <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script>
  58.         <script type="text/javascript" src="js/jquery.maskedinput.js"></script>
  59.         <script type="text/javascript" >
  60.             $(document).ready(function() {
  61.                 $('table#horario tbody tr:odd').addClass('impar');          
  62.                 $('table#horario tbody tr:even').addClass('par');          
  63.             });  
  64.         </script>
  65.     </head>
  66.  
  67.     <body>
  68.         <?php
  69.             if (!isset($_SESSION['funcionario'])){
  70.                 $user = unserialize($_SESSION['funcionario']);
  71.                 echo "<p>Você não esta autorizado para acessar essa area do sistema</p>";
  72.             }  // verificação para o login
  73.         ?>
  74.         <div class="global-div">
  75.  
  76.             <form method="post" action="buscahabilidade.php" >
  77.                 <fieldset>
  78.  
  79.                     <legend>Busca Habilidade</legend></br>
  80.                         <label  for="descricao" accesskey="">Habilidade:</label>
  81.                             <select name="descricao" id="descricao">
  82.                             <option value="descricao"> >> Selecione </option>
  83.                                 <?php
  84.                                 Banco::conecta();
  85.  
  86.                                 //clausula sql
  87.                                 $sql = "SELECT especialidade.cod_especialidade,especialidade.descricao FROM especialidade ORDER BY especialidade.descricao";
  88.  
  89.                                 //executa a clausula sql
  90.                                 $executar = mysql_query($sql)or die("Falha na execução da instrução SQL! ");
  91.  
  92.                                 //Verifica se a busca retornou resultado!
  93.                                 while($row = mysql_fetch_array($executar))
  94.                                 {
  95.                                     echo "<option value='".$row['cod_especialidade']."'>".$row['descricao']."</option>";
  96.                                 }
  97.                                 ?>
  98.  
  99.                             </select>
  100.                             <button name="cadastrar" type="submit">Buscar</button>
  101.                         </label>
  102.  
  103.                 </fieldset>
  104.             </form>
  105.  
  106.  
  107.             <?php
  108.             if (isset($_POST['cadastrar'])) {
  109.                 $sql1 = "SELECT pessoa.nome,pessoa.cod_pessoa,pessoa.ativo,pessoa.data_cadastro,especialidade.descricao
  110.                 FROM pessoa INNER JOIN artista ON pessoa.cod_pessoa=artista.pessoa_cod_pessoa INNER JOIN artista_has_especialidade
  111.                 ON artista.cod_artista=artista_has_especialidade.artista_cod_artista INNER JOIN especialidade ON artista_has_especialidade.especialidade_cod_especialidade=especialidade.cod_especialidade
  112.                 WHERE especialidade.descricao LIKE '%".$_POST['descricao']."%'order by 1";
  113.  
  114.                 // executa a query no banco de dados
  115.                 $executar = mysql_query($sql1)or die ("Query failed: " . mysql_error() . " Actual query: " . $sql1);;
  116.                 var_dump(mysql_query($sql1));
  117.                 var_dump(mysql_num_rows($executar));
  118.  
  119.                 // conta o total de resultados encontrados
  120.                 $total = mysql_num_rows($executar) or die(mysql_error());
  121.  
  122.                 // mensagem se o resultado for vazio
  123.                 // define valores se o resultado não for vazio
  124.  
  125.                 echo $total;
  126.  
  127.                 // gera o loop com os resultados
  128.                 echo"<table id="horario">";
  129.                 echo"<caption>";
  130.                     echo"Resultados da busca.";
  131.                 echo"</caption>";
  132.                 echo"<thead>";
  133.                     echo"<tr id="horizontal">";
  134.                         echo"<th>Nome</th>";
  135.                         echo"<th scope="col">Código</th>";
  136.                         echo"<th scope="col">Detalhes</th>";
  137.                         echo"</tr>";
  138.                 echo" </thead>";
  139.                 echo" <tfoot>";
  140.                   echo"<tr>";
  141.                        echo" <td colspan="6">Resultados da busca.</td>";
  142.                    echo" </tr>";
  143.                 echo"</tfoot>";
  144.                 echo"<tbody>"; // provavelmente o while começa aqui
  145.                 $i=0;
  146.                 $codigocarregaartista=array();
  147.                 while ($linha = mysql_fetch_array($executar)) {
  148.                 var_dump($linha);
  149.                 echo $linha['nome']." ".$linha['cod_pessoa'];
  150.                        $i++;
  151.                        echo" <tr>";
  152.                        echo" <th scope="row">".$linha['nome']."</th>";
  153.                        echo" <td>".$linha['cod_pessoa']."</td>";
  154.                        $codigocarregaartista[$i]=$linha['cod_pessoa'];                
  155.                        echo"  <td><a href="layoutartista.php?cod=".$codigocarregaartista[$i]."">Detalhes/Altera</a></td>";
  156.                        // link dinamico para alteracliente.php
  157.                        echo" </tr>";
  158.                        }
  159.                  echo" </tbody>";
  160.             echo"</table>";
  161.             }
  162.             ?>
  163.         </div>
  164.  
  165.         <!-- ListBox stuff == .js + SpryValidationSelect.css(integrated estiloformulario.css)-->
  166.         <script type="text/javascript">
  167.             var spryselect1 = new Spry.Widget.ValidationSelect("spryselect1");
  168.         </script>
  169.  
  170.     </body>
  171. </html>