我有一个名为prototype.php
的页面,并且有一个while循环,我回显按钮。当您单击该按钮时,您将被重定向到"proto.php?id=".$row['id']
并且在该页面上需要显示一个表,其中包含具有该按钮ID的行的内容。但我不知道如何将变量从prototype.php
传递到"proto.php?id=".$row['id']
这是我的while循环:
<?php
$sql = "SELECT * FROM theme";
$result = $con->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
$your_url= "proto.php?id=".$row['id'];
echo '<a href="'.$your_url.'"><input type="button" value="'. $row["theme_name"].'"></a>';
}
} else {
echo "no results";
}
?>
这是"proto.php?id=".$row['id']
:
$row = $_GET['id'];
// Attempt select query execution
$sql = "SELECT * FROM Norm LEFT JOIN Org ON norm.org_id = org.id LEFT JOIN Cluster ON norm.cluster_id = cluster.id LEFT JOIN Orden ON norm.orden_id = orden.id LEFT JOIN Users ON norm.user_id = users.id WHERE theme_id = $_GET['id']";
if ($result = mysqli_query($link, $sql)) {
if (mysqli_num_rows($result) > 0) {
echo "<table>";
echo "<tr>";
echo"<th>Norm Org</th>";
echo "<th>Norm id</th>";
echo "<th>Norm</th>";
echo "<th>Ordenen</th>";
echo "<th>Clusteren</th>";
echo "<th>Verantwoordelijke</th>";
echo "</tr>";
while ($row = mysqli_fetch_array($result)) {
if ($row['orden_name']) {
$data_list = $row['orden_name'];
} else {
$data_list = $dropdown_list;
}
if ($row['cluster_name']) {
$data_list2 = $row['cluster_name'];
} else {
$data_list2 = $dropdown_list2;
}
if ($row['user_name']) {
$data_list3 = $row['user_name'];
} else {
$data_list3 = $dropdown_list3;
}
echo "<tr>";
echo "<td>" . $row['org_name'] . "</td>";
echo "<td class='row_count'>" . $row['norm_id'] . "</td>";
echo "<td>" . $row['norm_name'] . "</td>";
echo "<td>" . $data_list . "</td>";
echo "<td>" . $data_list2 . "</td>";
echo "<td>" . $data_list3 . "</td>";
echo "</tr>";
}
echo "</table>";
// Free result set
mysqli_free_result($result);
}else{
echo "No records were found.";
}
} else {
echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
}
有人能帮助我吗?
答案 0 :(得分:0)
更改 proto.php 此行:WHERE theme_id = '1'";
:WHERE theme_id = " . $_GET['id'] . ";";