0
I am learning to work with PHP and I would like to know how to show two arrays of a single variable.
I am making a selection of the bank that sends me two arrays, I would like to know how to show them.
In the $res variable comes two arrays, and I would like to show the key and the value. With foreach works, but brings only one 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>
And what would be the "two arrays"? How do you want to display?
– Woss
Does the above code present an error? You are displaying the key and the value of the associative array, theoretically it is correct.
– Matheus Picioli
In the $res variable comes two arrays, and I would like to show the key and the value. With foreach works, but brings only one array.
– Sumback