行,所以我有一個簡單的PHP腳本選擇,我有下面的代碼來定義變量。傳遞PHP選擇元素融入到一個URL
$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選擇腳本變量傳遞到網址被點擊的<a>
時。
所有我最終是account/practiceSheets?id=
沒有實際的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);
}
?>
請重新格式化您的代碼 – 2013-07-29 03:38:03
是的,我不是故意要提交:(對不起!! – user2371301
有一件事......你需要將值連接到字符串 - 就像你在其他地方做的一樣同樣的代碼:'回聲「」;'(還有其他的方法可以做到這一點,請參閱該文檔:http://php.net/manual/en/language.operators.string.php)你有一個額外的單引號在那裏。 –