我有一个来自上一页的 javascript 变量,它作为“namer”传递给标题。现在我还想在 php 的 sql 查询中使用该变量。如何将此javascript变量作为变量“namer”发送到服务器端的php?
<!DOCTYPE html>
<html>
<head>
<title>My Page</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" />
<script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
<script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"> </script>
</head>
<body>
<script>
$( document ).ready(function() {
var namer = sessionStorage.getItem("namer");
$('h1').text(namer)
});
</script>
<div data-role="page" class="div1">
<div data-role="header">
<h1>"namer"</h1>
</div>
<div data-role="content">
<?php
$link = mysql_connect("xxxx", "xxxx", "xxxx") OR DIE ("Unable to connect to database! Please try again later.");
mysql_select_db("abxusername");
$query = "SELECT class FROM Antibiotics WHERE name="."namer".";";
echo $query;
echo mysql_query($query);
?>
</div>
</div>
</body>
</html>