niche Posted November 13, 2011 Share Posted November 13, 2011 What's the notation to redefine a php variable as a javascript varible? <?phpinclude 'connect_to_mysql.php';$results = mysql_query("SELECT * FROM plan WHERE TIMESTAMP(NOW()) < TIMESTAMP(end)") or die(mysql_error());$phpVar = mysql_num_rows($results); echo '<script type="text/javascript">';echo 'var x = ???????????';echo 'document.write("<p>" + x + "</p>")';echo '</script>';?> Link to comment Share on other sites More sharing options...
dsonesuk Posted November 14, 2011 Share Posted November 14, 2011 What like <?phpinclude 'connect_to_mysql.php';$results = mysql_query("SELECT * FROM plan WHERE TIMESTAMP(NOW()) < TIMESTAMP(end)") or die(mysql_error());$phpVar = mysql_num_rows($results); echo '<script type="text/javascript">';echo 'var x = '.$phpVar.';';echo 'document.write("<p>" + x + "</p>")';echo '</script>';?> Link to comment Share on other sites More sharing options...
niche Posted November 14, 2011 Author Share Posted November 14, 2011 Perfect! Thanks dsonesuk. EDIT: Changed to:echo 'document.write("<p>" + x + "</p>");'; Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.