<?php
$query3 = "SELECT message FROM messageslive LIMIT 1";
$result3 = mysql_query($query3,$connection) or die (mysql_error());
confirm_query($result3);
while($userinfo3 = mysql_fetch_array($result3)){
$msgLive = $userinfo3['message'];
}
?>
<script type="text/javascript">
var msg = "<?php echo $msgLive ; ?>";
</script>
What I worry is when the database table has too many data to search and retrieve, so PHP variable $msgLive
doesn't have value yet, so Javascript variable var msg
get empty value. How to ask javascript wait until PHP variable $msgLive
got the value then only transfer the value from php variable to Javascript?