我试图在HTML表格上显示每篇文章的类别,但没有提供任何错误。显示数据库中的类别
那么,查询是好的。我没有发现任何一种拼写错误的变量。
<?php
$query = "SELECT * FROM posts";
$se_posts = mysqli_query($connection,$query);
while ($row = mysqli_fetch_assoc($se_posts)) {
$post_id = $row['post_id'];
$post_author = $row['post_author'];
$post_title = $row['post_title'];
$post_category_id = $row['post_category_id'];
$post_status = $row['post_status'];
$post_image = $row['post_image'];
$post_tags = $row['post_tags'];
$post_comment_count = $row['post_comment_count'];
$post_date = $row['post_date'];
echo "<tr>";
echo "<td>{$post_id}</td>";
echo "<td>{$post_author}</td>";
echo "<td>{$post_title}</td>";
// show post category
$query = "SELECT * FROM categories WHERE cat_id Like $post_category_id";
$query_update_cat = mysqli_query($connection, $query);
while ($row = mysqli_fetch_assoc($query_update_cat)) {
$cat_id = $row['cat_id'];
$cat_title = $row['cat_title'];
echo "<td>{$cat_title}</td>";
}
echo "<td>{$post_status}</td>";
echo "<td><img class='img-responsive' width='100'src='../images/{$post_image}'></td>";
echo "<td>{$post_tags}</td>";
echo "<td>{$post_comment_count}</td>";
echo "<td>{$post_date}</td>";
echo "<td><a href='post.php?delete={$post_id}'>delete</a></td>";
echo "<td><a href='post.php?source=edit_post&p_id={$post_id}'>Edit</a></td>";
echo "</tr>";
}
?>
问题是什么? – Raptor
你检查了图像吗? – Alan
你已经写过 echo“{$ post_status}”;显示状态。尝试删除它。 –