所以我需要 php 来存储 $aid,它应该是用户当前正在评论的文章的 ID,但是它总是将它保存为 0,例如当我在页面 localhost/article.php?article_id =69 并写 echo $aid; 它会回显 69,但是当我想将它存储到数据库中时,它只是将它存储为 0
if (isset($_GET['article_id'])) {
include("mySQLcon.inc.php");
$aid = mysql_real_escape_string($_GET['article_id']);
$query = "SELECT * FROM front_articles WHERE id = '$aid'";
$sql = mysql_query($query);
}
while ($articles = mysql_fetch_object($sql)) {
?>
<div id="IApage">
<?php
echo '<b>' . $articles->title.'</b>'.'<br>'.
$articles->message. '<br>';
?>
</div>
<?php
}
if(isset($_COOKIE['user'])){
?>
<div id="article_comment_form">
<form id="arti_com_form" name="article_com_for" method="post" action="article.php">
<textarea name="comment" rows="7" cols="50"></textarea><br>
<input name="com_submit" type="submit" value="Comment"/>
</form>
</div>
<?php
}
if (isset($_POST['com_submit'])) {
$comment_message = $_POST['comment'];
$comment_query = mysql_query("INSERT INTO front_article_comments (article_id, poster_id, poster_username, message, date) VALUES ('$aid', '$poster_id', '$username', '$comment_message', NOW())");
}
echo $aid;
?>