我被卡住了。我有一些页面可以在数据库上编辑字段。我可以看到任务,我想通过单击"编辑"按钮中的"编辑"one_answers"重定向到页面",在其中将使用" nome"(名称)显示有关该任务的信息,因为它的唯一管理如何将名称从一个页面传输到另一页。
代码是:
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...
我通常使用帖子在数据库上显示数据,但我希望这是不同的。
有人可以帮我吗?
谢谢。
使用$_GET['Nome']
获取URL参数的值。在进行查询之前,您需要将其分配给变量($Nome
),显然
当您使用用户编辑数据进行查询时,您应该考虑使用准备好的语句进行安全性。
使用会话
<?php
session_start();
// store session data
$_SESSION['name']=$row[Nome]; // $_SESSION['name'] will carry your data until session end
?>
在另一页上
<?php
session_start();
// store session data
$nome=$_SESSION['name'];
?>
参考http://www.w3schools.com/php/php_sessions.asp