コード内の値 ID を edit.php に渡すのに問題があります。
displaynews では、データベースから記事を印刷します。また、edit.php にリダイレクトして $id 値を送信するリンクも作成します。
displaynews 機能へのリンク
困っているところはここ
<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' ");
}
?>