Jump to content

Php Variable Into Javascript Variable - Solved With Thanks


niche

Recommended Posts

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

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

Perfect! Thanks dsonesuk. EDIT: Changed to:echo 'document.write("<p>" + x + "</p>");';

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...