After reading the data from the DB, you can use foreach to output all the data. But I want to print out the printed data as an alert at once, what should I do?
this is my code
foreach($result as $row){
print_r("excel_number:".$row['excel_index']." / "."fail_reason:".$row['reson_result']."<br>");
}
$total_fail_log = "excel_number:".$row['excel_index']." / "."fail_reason:".$row['reson_result']."<br>";
echo "<script>alert('$total_fail_log');</script>";
and print result
and alert result
When output as alert, only the last value is output. How do I print out the whole thing like the first picture?
2
Answers
You can put the alert inside the foreach loop and it will be executed from inside. By doing this, according to the output, you should have two alerts.
Concatenate all your data to a string. Then pass the sctring to an alert function.
Feel free to tweak the code according to your need.