我有一个php标签,我试图从数据库中检索得到一些值。然后将这些值声明给一个变量,然后利用这些变量将值传递给html body标签。
PHP: <?php
$sql = "SELECT * FROM productItem;";
// Write a statement to open a connection to MySQL server
$link = mysql_connect("localhost:3306", "root", "6i7yvBku");
// Write a statement to select the required database
mysql_select_db("KXCLUSIVE", $link);
// Write a statement to send the SQL statement to the MySQL server for execution and retrieve the resultset
$resultset = mysql_query($sql);
// Write a statement to close the connection
mysql_close($link);
$year = $row["year"];
$month = $row["month"];
?>
HTML: <body onload="countdown(year,month)">
我该如何把php变量($year和$month)放入html正文标签(以取代正文标签中的年和月变量??
<body onload="<?php echo "countdown($year,$month)" ; ?>">
this应该做…并且为了将来的参考,不要使用mysql_,它们已经贬值了,使用mysqli/PDO http://php.net/manual/en/changelog.mysql.php