You are giving the following error:
Notice: Undefined variable: report in C: \ xampp \ htdocs \ nise \ general.php online 262
Warning: Invalid argument supplied for foreach () in C: \ xampp \ htdocs \ nise \ general.php on line 262
Line 262 is where this code snippet is:
<?php foreach ( $denuncia as $den ) { ?>
.
<?php
if(!empty($_FILES['uploaded_file'])){
$username = 'root';
$password = '';
$connection = new PDO( 'mysql:host=localhost;dbname=nise', $username );
$query = "INSERT INTO resposta_denuncia (descricao_resposta, imagem, id_usuario)
VALUES (:descricao_resposta, :imagem, :id_usuario)";
$statement = $connection->prepare($query);
$path = "img_denuncia/";
$path = $path . basename( $_FILES['uploaded_file']['name']);
if(move_uploaded_file($_FILES['uploaded_file']['tmp_name'], $path))
$valores = array();
$valores[':descricao_resposta'] = $_POST['descricao_resposta'];
$valores[':imagem'] = $_FILES['uploaded_file']['name'];
$valores[':id_usuario'] = 2;
if(!isset($_POST['descricao_resposta']) or empty($_POST['descricao_resposta'])) {
echo 0;
}elseif($result = $statement->execute($valores)) {
echo 1; // dados enviados com sucesso
} else {
echo 0; // erro ao tentar enviar dados
}
//criei a query
$query = "SELECT id, data, descricao, imagem, image FROM denuncia";
//prepara a query
$statement = $connection->prepare($query);
//executar o comando sql
$result = $statement->execute();
//juntar todos os resultados do select em um vetor de arrays
$statement->execute();
$denuncia = $statement->fetchAll();
return $denuncia;
}
?>
table
<!--Começo da tabela-->
<div class="card mb-3">
<div id="wrapper">
<div id="content-wrapper">
<div class="container-fluid">
<div class="card-body">
<div class="table-responsive">
<table class="table table-bordered" id="dataTable" width="100%" cellspacing="0">
<thead>
<tr>
<th id="id_bd">Nº</th>
<th id="date">Data e hora</th>
<th id="local">Local</th>
<th id="comentario">Comentário</th>
<th id="imagem">Imagem</th>
</tr>
</thead>
<?php foreach ( $denuncia as $den ) { ?>
<tr>
<td><?php echo $den["id"];?></td>
<td><?php echo $den["data"];?></td>
<td><?php echo $den["descricao"];?></td>
<td><?php echo $den["imagem"];?></td>
<td><?php echo $den["qual_descricao"];?></td>
</tr>
<?php } ?>
</table>
</div>
</div>
<div class="card-footer small text-muted">Atualizado ontem às 11:59 PM</div>
</div>
</div>
</div>
</div>
<!--Começo da tabela-->