Skip to content
Advertisement

Inserting value in a JavaScript variable from php code

I am trying to test the following code for inserting the value from PHP code to my javascript variable x

tested the PHP code, and it’s giving the correct output but the alert box in the javascript shows this –

date_sub(curdate(),interval 1 day) and activity=1 group by code having b > 1000″; $query = mysql_query($myquery); if ( ! $myquery ) { echo mysql_error(); die; } $data = array(); for ($x = 0; $x < mysql_num_rows($query); $x++) { $data[] = mysql_fetch_assoc($query); } //echo json_encode($data); echo ”; mysql_close($server); ?>

JavaScript

Advertisement

Answer

JavaScript

Then:

JavaScript

you need to insert id="myPhpValue", because you used the "getElementById";

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement