【发布时间】:2019-03-06 09:31:37
【问题描述】:
我支持数据库,如何将变量从一个页面共享到另一个页面?
我的页面choose.php 在加载时会生成以数据库表的字段值作为值的按钮。 我必须确保在单击按钮时: - 为我保存一个表格数据(“id”) - 我被重定向到另一个页面 - 在我被重定向以获取变量并将其放入查询的页面上
有可能吗?如果有怎么办?
<!DOCTYPE html>
<?php
session_start();
if(!isset($_SESSION["username"])){
header('location: ../index.php');
}else
{
?>
<?php
$servername = "localhost";
$username = "";
$password = "";
$dbname = "";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT idCantiere,nomeCantiere,codiceCommessa,indirizzoCantiere FROM Cantiere";
$result = $conn->query($sql);
echo'<h1> <font face="verdana" color="green">Quale Cantiere desideri Modificare?</font> </h1>';
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
echo'<br><br><br>';
echo'<a href="#" class="myButton" alt="">' . $row["nomeCantiere"] . '</a>';
}
echo'<br><br><br>';
echo '<a href="../pagineHtml/inserimento/inserimentoGenerale/inserimentoCantiere.php" class="myButton" alt="Nuovo Cantiere +">Nuovo Cantiere +</a>';
} else {
echo "0 results";
}
$idCantierePerSelect = $_POST["idCantiere"];
global = $idCantierePerSelect;
echo $idCantierePerSelect;
$conn->close();
?>
目前我只设法自动加载按钮... 我想把“idCantiere”,这是我必须从一个表转到另一个表的字段,全局
【问题讨论】:
标签: php html mysql web-applications