Inputbox from php and oracle

0

I want to show as options the result of this query to later use them.

$qsucursal = oci_parse($conn, 'SELECT Id_Sucursal, Sucursal FROM TblSucursales;'); //Consulta
oci_execute($qsucursal);//Ejecutando consulta

I go through the results and put them in an input, but it does not work.

while(($fila= oci_fetch_array($qsucursal, OCI_BOTH)) != false)
        { 
           echo '<input type="checkbox" name="'.$fila["Id_Sucursal"].'" value="'.$fila["Sucursal"]'">';
        }
    
asked by Francisco Guillermo Herrera Ga 28.08.2017 в 21:16
source

1 answer

0

First of all, it is necessary to keep the flow of the program under control at all times, indicating pertinent messages that indicate what is happening.

In that control, you should check:

  • That the connection works
  • That the query shows data
  • If you throw data read it
  • Close resources

Regarding data reading, you might be having problems with the mix of single quotes ' and double quotes " .

To avoid that confusion, it is better to build a variable within the loop:

$html="";
while(($fila= oci_fetch_array($qsucursal, OCI_BOTH)) != false)
        { 

           $id_sucursal=$row["Id_Sucursal"];
           $sucursal=$row["Sucursal"];
           $html.="<input type='checkbox' name='$id_sucursal' value='$sucursal'>";

        }

//Imprimes la variable que se creó 
echo $html;
    
answered by 29.08.2017 в 00:46