我被困住了。我有一些頁面可以編輯我的數據庫中的字段。我可以看到這些任務,並且我想通過點擊「編輯」按鈕來編輯它們,並重定向到將顯示有關該任務的信息的頁面,使用「Nome」(名稱),因爲它的唯一性,但是我不能管理如何將名稱從一個頁面轉移到另一個頁面。編輯頁面Mysql數據的PHP
的代碼是:
eventos.tarefas.php
while($row = mysqli_fetch_array($result))
{
echo "<tr>";
echo "<td width=5%>" . $row[Nome] . "</td>";
(...)
echo "<td width=10%>" . $row['Evento'] . "</td>";
echo ("<td><a href=\"editar_tarefa.php?Nome=$row[Nome]\">Editar</a></td></tr>"); //I'm stuck in this line
echo "</tr>";
}
editar_tarefa.php
<?php
$con=mysqli_connect("","","","");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$result = mysqli_query($con,"SELECT * FROM tarefas WHERE Nome= '$Nome'");
echo $Nome;
while($row = mysqli_fetch_array($result))
{
?>
<table width="744" height="697">
<tr>
<td width="188" height="10"><p style="font-size:30px; font-family:verdana;">ID</p></td>
<td>
<input type="text" readonly name="ID" size="20" value="<?php echo "$row[ID]"?>" style="width: 400px; height:30px; font-size:150%;background-color:#EEE9E9">
</td>
</tr>
<tr>
(...) and so on...
我通常使用POST上顯示數據庫中的數據,但我想這不一樣。
有人可以幫助我嗎?
謝謝。
使用'$ _GET ['Nome']'獲取URL參數的值。在進行查詢之前,您需要將它分配給一個變量('Nome'),顯然 – ElendilTheTall
謝謝!像魅力一樣工作! :D –
樂意提供幫助。如果你願意接受,我已經把它作爲答案;) – ElendilTheTall