我试图从我的页面1上的表单中获取一个变量到我在第2页上进行的查询,这样当查询工作时它将使用第1页上输入的变量
Page 1表格
<form method="post" action="testformQ.php">
<input type="text" name="testform">
<input type="submit">enter
第2页查询
'$software = mysql_query("SELECT software.SoftwareID, rooms.RoomID
FROM softwareroom
INNER JOIN software
ON software.SoftwareID=softwareroom.SoftwareID
INNER JOIN rooms ON rooms.RoomID=softwareroom.RoomID
WHERE rooms.RoomNum=$_GET[testform]"); (the where clause is where i want the variable)
while($rec = mysql_fetch_array($software))
{
echo $rec['SoftwareID'] . " " . $rec['RoomID'];
}'
所以GET testform在查询中的位置是我想要表单变量的地方。 任何帮助将不胜感激
答案 0 :(得分:0)
此代码适用于您
$data = $_REQUEST['testform'];
$software = mysql_query("SELECT software.SoftwareID, rooms.RoomID
FROM softwareroom
INNER JOIN software
ON software.SoftwareID=softwareroom.SoftwareID
INNER JOIN rooms ON rooms.RoomID=softwareroom.RoomID
WHERE rooms.RoomNum='$data'");
while($rec = mysql_fetch_array($software))
{
echo $rec['SoftwareID'] . " " . $rec['RoomID'];
}'
答案 1 :(得分:0)
对此进行Page02查询。
$servername = "servername";
$username = "username";
$password = "password";
$db = "db_name";
$query = "SELECT software.SoftwareID, rooms.RoomID FROM softwareroom INNER JOIN software ON software.SoftwareID = softwareroom.SoftwareID"
+ "INNER JOIN rooms ON rooms.RoomID = softwareroom.RoomID WHERE rooms.RoomNum = '$_POST["testform"]'";
//Create db connection
$connection = mysqli_connect($servername, $username, $password, $db);
//Check connection
if(!$connection){
echo "Failed to connect to database ".mysqli_connect_error();
}
$software = mysqli_query($connection, $query);
mysqli_close($connection);