Divide form with radii into 2 columns

1

I have the following form:

 <?php  
echo"<form class='form-horizontal' method='POST' action='reposicao.php'>"; 
  echo"<fieldset>";
    echo"<legend>OPÇÕES</legend>";
  echo"<input type='hidden' name='loja'     id='loja'     value='$v_loja'>";

  $query_menu = mysql_query("SELECT 
  rm_id     AS FUNCAO,
  rm_desc   AS DESCRICAO,
  rm_obs    AS OBSERVACAO,
  rm_status AS STATUS 
       FROM radios_menu 
            WHERE rm_status='0'");
    while ($row = mysql_fetch_array($query_menu)) {
    $v_funcao    = $row["FUNCAO"];
    $v_desc      = $row["DESCRICAO"];
    $v_obs       = $row["OBSERVACAO"];
    $v_status    = $row["STATUS"];
    echo"<div class='form-group'>";
      echo"<label class='col-lg-2 control-label'></label>";
      echo"<div class='col-lg-10'>";
        echo"<div class='radio'>";
          echo"<label>";
            echo"<input type='radio' name='v_desc' id='$v_funcao' value='$v_funcao' >$v_desc </label></br>";
        echo"</div>";
      echo"</div>";
    echo"</div>";
           }
     echo"<input type='hidden' name='v_descricao'     id='$v_desc'     value='$v_desc '>";
     echo"<br />";
     echo"<br />";
    echo"<div class='form-group'>";
      echo"<div class='col-lg-10 col-lg-offset-2'>";
        echo"<button type='submit' class='btn btn-primary'>CONSULTAR</button>";
      echo"</div>";
    echo"</div>";

  echo"</fieldset>";
 echo"</form>";
?>

It lists several radios, but you're listing everything underneath the other as you could to list 2 columns?

    
asked by anonymous 23.06.2016 / 23:23

3 answers

2

To list side by side you would have to define a width, since div comes by default with 100% width, thus occupying all the space and moving to the next line.

Since the div found radios is set with col-lg-10 , that is, using 10, to make two columns you should set for each div within this col-lg-5 , as answered by @ Davi Sousa.

I reviewed your code with this and a few more changes to make the code cleaner, as follows:

<?php 

echo "
<form class='form-horizontal' method='POST' action='reposicao.php'> 
  <fieldset>
    <legend>OPÇÕES</legend>
      <input type='hidden' name='loja' id='loja' value='$v_loja'>";

        $query_menu = mysql_query("SELECT 
          rm_id     AS FUNCAO,
          rm_desc   AS DESCRICAO,
          rm_obs    AS OBSERVACAO,
          rm_status AS STATUS 
        FROM radios_menu 
        WHERE rm_status='0'");

        while ($row = mysql_fetch_array($query_menu)):
          $v_funcao    = $row["FUNCAO"];
          $v_desc      = $row["DESCRICAO"];
          $v_obs       = $row["OBSERVACAO"];
          $v_status    = $row["STATUS"];

           echo "
           <div class='form-group'>
             <label class='col-lg-2 control-label'></label>
               <div class='col-lg-10'>
               // Aqui vai a classe
                 <div class='radio col-lg-5'>
                   <label>
                     <input type='radio' name='v_desc' id='$v_funcao' value='$v_funcao' >$v_desc 
                   </label>
                   </br>
                 </div> 
               </div>
             </div>";

         endwhile;

         echo "
         <input type='hidden' name='v_descricao' id='$v_desc' value='$v_desc '>
         <br />
         <br />
         <div class='form-group'>
           <div class='col-lg-10 col-lg-offset-2'>
             <button type='submit' class='btn btn-primary'>CONSULTAR</button>
           </div>
         </div>
       </fieldset>
     </form>";

?>

Remembering that I changed the code to be more readable, since it is not necessary to have so many echo , but it is not a necessary change, it's up to you.

I hope I have helped;

Att;

    
24.06.2016 / 13:42
0
 echo"<div class='radio'>";
      echo"<label>";
        echo"<input type='radio' name='v_desc' id='$v_funcao' value='$v_funcao' >$v_desc </label></br>";
    echo"</div>";

CHANGE FOR

 echo"<div class='radio col-lg-5'>";
      echo"<label>";
        echo"<input type='radio' name='v_desc' id='$v_funcao' value='$v_funcao' >$v_desc </label></br>";
    echo"</div>";
    
24.06.2016 / 02:01
0

Set a width to its radio div and set float: left .

    
24.06.2016 / 01:23