I would like to know how I can fix the following problem I'm having with the alert
response. I do INSERT
of items to MySQL
, so far so good. However, if some files fail and others can be sent in the loop warning, alert
of the error message.
I would like to know how I can change the code below to work as follows:
Count the total value of data sent successfully and data that failed to send, thus being able to stay with only alert
, eg:
Total submissions with Hit X with X failure .
<?php
for($i=1; $i<=$total; $i++) {
// Insere os dados no banco de dados
$sql = $MySQLiconn->query("INSERT INTO 'medias' SET 'cat'='".$subcat["cat"]."', 'subcat'='".$subcat["id"]."'");
}
if($sql) { ?><script>
alert('<?php echo $total." Itens inseridos com sucesso !!!"; ?>');
window.location.href='index.php';
</script><? }
else {
?>
<script>
alert('error Erro ao tentar inserir os itens tente nova mente');
</script>
<?
}
?>