How to set javascript to wait for mysql value for php variable?

<?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>

I am worried when the database table contains too much data to search and retrieve, so the PHP variable $msgLivedoesn't matter yet, so the Javascript variable var msggets an empty value. How to set javascript until the PHP variable $msgLivegets the value and then passes the value from the php variable to Javascript?

+2
source share
1 answer

, script, , msgLive , , HTML-, . (, , - , :-)). , HTML , javascript . javascript , javascript , HTML .

+8

All Articles