Pass a select with mysqli_fetch_row to a table



PHP Snippet 1:

$conexion=mysqli_connect('localhost','root','mysql','venta3');
$continente=$_POST['continente'];
    // Build the query with ? to prepare later
    $sql1="SELECT cobro, debe,idEntrega FROM inventario Where (idCliente=? AND (cantidadP>0 or cantidadM>0 OR cantidadG>0))";
    // Prepare the statement
    $stmt = $conexion->prepare($sql1);
    // Bind the params
    $stmt->bind_param("s", $continente);
    // Attempt to execute
    if ($stmt->execute()) {
        // if successful, get result
        $result = $stmt->get_result();
        // If query brought any rows
        if ($result->num_rows > 0) {
            // build the select
            $cadena2="<select id='cobroDebe' name='cobroDebe' style='width:400px;'  class='chosen-choices2'>";
            // Fetch assoc array from the result
            while ($ver2 = $result->fetch_assoc()) {
                // use it
                $cadena2=$cadena2."<option value='". $ver2[1] ."'>". $ver2[1] ."</option>";
            }
            echo  $cadena2."</select>";
        }
    // if execution failed - echo the error
    } else {
        echo $stmt->error;
    }
    // free result and close statement
    $result->free_result();
    $stmt->close();
    // You can reuse $stmt and $result because we've now freed them