我正在尝试从 mysql 数据库中获取我的类别以显示,并通过 php 包含将其添加到我的索引页面,这是类别页面虽然这是我收到错误的地方,但不知道为什么?
<?php //which category are we showing?
$category_id = $_GET['catid']; ?>
<h2>All Categories</h2>
<?php
//get 2 latest published posts
$query_latest = "SELECT title, body, date, category_id, post_id
FROM posts
WHERE is_published = 1
AND category_id = $category_id
ORDER BY date DESC";
//run the query code on the DB
$result_latest = mysql_query( $query_latest );
//loop it, work with one post at a time
while( $row_latest = mysql_fetch_array( $result_latest ) ){ ERROR ROW 19
?>
<div class="post">
<h2><?php echo $row_latest['title'] ?></h2>
<h3>Posted on <?php echo $row_latest['date']; ?> in the category of something</h3>
<p><?php echo $row_latest['body'] ?></p>
</div>
<?php } //end while loop ?>
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given
in C:\xampp\htdocs\schellshockdesign.com\term5final\finalproject\category.php
on line 19