我无法将代码中的值id传递给edit.php。PHP传递值
在displaynews中,我从数据库中打印出文章。它还创建了一个链接,将我重定向到edit.php并发送$ id值。
链接displaynews功能
这里的地方的具有1M麻烦
<h3>EDIT NEWS ARTICLE</h3>
<form id="EditNews" name="EditNews" method="POST" action="edit.php">
<textarea name="editnewstext"><?php $news=Textarea(1);echo $news ?></textarea> <!--HERE i need to replace the 1 with id passing in displaynews -->
<input type="submit" name="Edit_News" id="Edit_News">
<?php
include 'db.php';
include'editnewsarticle.php';
if(isset($_POST['Edit_News']))
{
$content= $_POST['editnewstext'];
geteditnews(1,$content); //<!--HERE i need to replace the 1 with idpassing in displaynews -->
Header("location:Home.php");
}
链接Edit.php页
链接GetnewsTextarea功能
链接到editnewsarticle功能
请不要在MySQL扩展是如何贬值,我的代码是开放的SQL注入评论。 在此先感谢
编辑:这里是解决方案
if(isset($_GET['id']))
{
$id = $_GET['id'];
$data = mysql_query("SELECT * FROM news WHERE id = '$id' ");
}
?>
'Header(“location:Home.php”);如果您已经打印了任何内容,您已经完成了''将不起作用。此外,以这种方式合并HTML和PHP并不正确,但实际上很难遵循,我建议您将HTML代码附加到变量并在最后回显。这也使'header()'函数可以工作,因为直到最后才打印任何东西。 – Naryl 2013-03-20 12:38:51
@Naryl谢谢你这样做 – Dynamiite 2013-03-20 12:45:29