Advertisement
bulfaitelo

função vetor drop down option

Nov 9th, 2012
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.42 KB | None | 0 0
  1.   function criar_dropdown_sabor_sorvete($id_recebido, $id_idioma)
  2.     {
  3.        
  4.        if($id_idioma!=null)
  5.        {
  6.        
  7.             /** encontra os valores para fazer acompraração e deixar selected **/
  8.             $query_verificar ="SELECT * FROM ins_inscricao_sabores where id_inscricao='$id_recebido'";
  9.             $result_verificar = consulta_mysql($query_verificar);
  10.            
  11.                 while($row_verificar= mysql_fetch_array($result_verificar, MYSQL_ASSOC))
  12.                 {
  13.                     $vetor_id_sabor[] = $row_verificar['id_sabor'];
  14.                 }
  15.        
  16.         }
  17.        
  18.        
  19.         /** aqui enconta no banco a listagem dos sabores...**/
  20.         $query = "SELECT * FROM ins_sabores";
  21.         $resultado= consulta_mysql($query);
  22.        
  23.             while($row= mysql_fetch_array($resultado, MYSQL_ASSOC))
  24.             {
  25.                 $id_sabor = $row['id_sabor'];
  26.                 $sabor = $row['sabor'];
  27.                
  28.                 if($id_sabor==in_array($id_sabor, $vetor_id_sabor))
  29.                 {
  30.                     $resultado_option.= "<option selected='selected' value='$id_sabor'> $sabor </option>";    
  31.                 }  
  32.                 else
  33.                 {
  34.                     $resultado_option.= "<option value='$id_sabor'> $sabor </option>";
  35.                 }      
  36.                
  37.             }
  38.  
  39.         return $resultado_option ;
  40.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement