【发布时间】:2019-03-06 07:18:10
【问题描述】:
如何根据用户按下的按钮将用户重定向到另一个 php 页面? 例如..我希望一旦加载页面,就会在其中生成包含从数据库中获取的表的“id”的按钮......单击按钮时,您将被重定向到一个页面,其中有文本框属于表 id 的字段..
<?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="#" onClick=navigaButton(); class="myButton" alt="">' . $row["nomeCantiere"] . '</a>';
// echo '<a href="#" class="rainbow-button" alt="' . $row["nomeCantiere"] . '"></a>';
//''<input type="button" value="' . $row["nomeCantiere"] . '" />'
}
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;
function navigaButton()
{
// FUNCTION That redirect to the page
};
$conn->close();
?>
所以我必须拿起“idCantire”,我必须确保通过单击打开我的页面上的按钮,有带有“idCantire”表格数据的文本框
【问题讨论】:
-
函数
navigaButton需要是javascript,你需要以某种方式传递它的id。 -
@RamRaider 感谢您的回复,但我该如何传递呢?
标签: php html mysql web-applications