我的頁面左側有一個菜單,列出帖子的所有標題。如何根據帖子ID以博客系統的形式顯示帖子
menu.inc.php
<?php $rArticles = selectArticles($conn); ?>
<ul class="menu">
<?php while($row = mysqli_fetch_array($rArticles)){ ?>
<li><a href="index.php?page=articleform"><?php echo $row['artTitre'];?></a></li>
<?php } ?>
</ul>
我想發生這樣的是,當我點擊標題,帖子將在頁面上顯示:
<?php $rArticles = selectArticles($conn); ?>
<h2>Articles <span><a class="btn" href="index.php?page=articleform">Ajouter un article</a></span></h2>
<div class="article">
<h3>
<?php
$rows = mysqli_fetch_array($rArticles);
$rArticlesId = selectArticleById($rows['artID'], $conn);
while($row = mysqli_fetch_array($rArticlesId)){
?>
<a href="index.php?page=articleform&article=<?php echo $rows['artID']?>"> <?php echo $rows['artTitre']; ?></a>
<span><a class="btn" href="index.php?page=articles&action=delete&item=<?php echo $rows['artID'];?>">supprimer</a></span>
</h3>
<p><em><?php echo $rows['artDate']; ?> - <?php echo $rows['artAuteur']; ?></em></hp>
<p><?php echo $rows['artContenu']; ?></p>
<fieldset>
<legend> Commentaires </legend>
<?php
$rComm = selectCommentairesByIdArticle($rows['artID'], $conn);
while($row = mysqli_fetch_array($rComm)){
?>
<p>
<a href="index.php?page=commentaires&action=delete&item=<?php echo $row['commentID'];?>"><img src="images/cross.png" /></a>
<strong><?php echo $row['commentPseudo']; ?> </strong><?php echo $row['commentText']; ?>
</p>
<?php } ?>
<form action="index.php?page=commentaires&action=insert" method="post">
<table class="admin_form" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td width="30%"><label for="PseudoCommentaire">Pseudo</label></td>
<td><input id="PseudoCommentaire" type="text" name="PseudoCommentaire" value="<?php if(isset($_POST['PseudoCommentaire'])) ?> " /></td>
</tr>
<tr>
<td valign="top"><label for="TexteCommentaire">Commentaire</label></td>
<td><textarea id="TexteCommentaire" name="TexteCommentaire"><?php if(isset($_POST['TextCommentaire'])) ?></textarea></td>
</tr>
<tr>
<td>
<input type="hidden" name="IdArticle" value="<?php echo $rows['artID'] ?>" />
</td>
<td>
<input type="submit" value="Envoyer le commentaire" />
</td>
</tr>
</table>
</form>
</fieldset>
<?php } ?>
</div>
我設置爲「刪除」和「添加」帖子,但根據帖子ID顯示和編輯失敗。我的數據庫連接和查詢工作正常。我認爲問題是指向頁面。你能告訴我這個嗎?
我認爲你需要傳遞的參數的帖子ID,似乎你不將href鏈接傳遞。 – Goikiu