How to show two arrays of a variable - PHP

0

I'm learning to mess with PHP and would like to know how to display two arrays of a single variable.

I'm making a selection of the bank that sends me two arrays, I'd like to know how I can display them.

In the variable $ res comes two arrays, and I'd like to show the key and value. With foreach working, but only after an array.

$sql = "SELECT * FROM formulario;";

$res = mysqli_query($mysqli, $sql);

$exibe = mysqli_fetch_assoc($res);

if ($res == false) {
   header("Location: erro.php");
}
?>

<!DOCTYPE html>
<html lang="pt-br" dir="ltr">
<head>
    <meta charset="utf-8">
    <title>index PHP</title>
</head>
<body>

    <form action="inserir/form-inserir.php" method="post">

        <?php foreach ($exibe as $chave => $valor) { ?>
            <h2> <?= $chave ?> </h2>
            <h4> <?= $valor ?> </h4>
        <?php } ?>

    </form>
    <form action="../index.php" method="post">
        <h1></h1>

        <input type="submit" value="Voltar ao index">
    </form>
</body>

    
asked by anonymous 04.09.2018 / 13:40

1 answer

0

I got it, it looked like this:

<?php while ($exibe = mysqli_fetch_assoc($res)) { ?>
     <?php foreach ($exibe as $chave => $valor) { ?>
         <h2> <?= $chave ?> </h2>
         <h4> <?= $valor ?> </h4>
     <?php } ?>
<?php } ?>
    
04.09.2018 / 13:52