好的,所以我有一个简单的 php 选择脚本,我有下面的代码来定义变量。
$result = mysqli_query($con,"SELECT * FROM practice_sheets WHERE student_name='$_SESSION[SESS_FIRST_NAME] $_SESSION[SESS_LAST_NAME]'");
$numrows = mysqli_num_rows($result);
$id = $row['id'];
$total_min = $row['total_min'];
$due_date = $row['due_date'];
然后我有:
echo "<td> <a href='account/practiceSheets?id='$id'> <i class='icon-eye-open'> </i> </a> </td>";
这应该在单击时将变量从 php 选择脚本传递到 url <a>
。
我最终得到的是account/practiceSheets?id=
没有实际身份的。我确定这是非常简单的事情,我很抱歉,因为我是 PHP 新手,也不知道该怎么称呼它才能在搜索引擎中获得可用的结果!如果有帮助,我的完整代码如下。
<?php
$con = mysqli_connect("50.63.106.47", "usd309bands", "MacBook1!", "usd309bands");
// Check connection
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$result = mysqli_query($con, "SELECT * FROM practice_sheets
WHERE student_name='$_SESSION[SESS_FIRST_NAME] $_SESSION[SESS_LAST_NAME]'");
$numrows = mysqli_num_rows($result);
$id = $row['id'];
$total_min = $row['total_min'];
$due_date = $row['due_date'];
if ($numrows == 0) {
echo "<div class='alert alert-danger'>";
echo "No Entries, See your instructor for details.";
echo "</div>";
} else {
echo "<table class='mws-table table-striped table-hover'>";
echo "<thead align='center'>";
echo "<tr>";
echo "<th>Sheet Number</th>";
echo "<th>Total Minutes</th>";
echo "<th>Due Date</th>";
echo "<th>View</th>";
echo "</tr>";
echo "</thead>";
echo "<tbody align='center'>";
while ($row = mysqli_fetch_array($result)) {
echo "<tr>";
echo "<td>" . $row['id'] . "</td>";
echo "<td>" . $row['total_min'] . "</td>";
echo "<td>" . $row['due_date'] . "</td>";
echo "<td> <a href='account/practiceSheets?id='$id'> <i class='icon-eye-open'> </i> </a> </td>";
echo "</tr>";
}
echo "</tbody>";
echo "</table>";
mysqli_close($con);
}
?>