I am using Js code inbetween php. I am trying make the body empty and append php text for every loop. php code works fine, but js works only when php has completed the script fully. Someone Please help
<?php
while($row = $result->fetch_assoc()){
$count++;
$email = "";
$email = $row['email_id'];
$result_row_count = $result->num_rows;
?>
<script type ="text/javascript">
$(document).ready(function(){
$("body").empty();
});
</script>
<?php
echo '<h4> Sending Mails '.$count.' of '.$result_row_count.' --- '.$email.'</h4>';
flush();
ob_flush();
sleep(1);
?>