I am a little confused on when you use the fetch() method and when you do not. Like in this case:
Why do I need the fetch() method here:
$query = "SELECT * FROM Idea_Categories WHERE categoryID = $category_id";
$category = $db->query($query);
$category = $category->fetch();
$category_id = $category['categoryID'];
$category_name = $category['categoryName'];
But not here:
$query = "SELECT * FROM statements WHERE categoryID = $category_id ORDER BY entryID";
$statements = $db->query($query);
I use $statements here and it just lists all the statements I have in the database:
<table>
<?php foreach ($statements as $statement) :?>
<tr>
<td><?php echo $statement['topic']; ?></td>
<td>
<form action="delete_line.php" method="post">
<input type="hidden" name="topic" value="<?php echo $statement['topic'];?>" />
<input type="hidden" name="category_id" value="<?php echo $statement['categoryID'];?>" />
<input type="submit" value="Delete" />
</form>
</td>
<td>
<form action="product_rate.php" method="post">
<input type="hidden" name="topic" value="<?php echo $statement['topic'];?>" />
<input type="submit" value="Upvote" name="action" />
</form>
</td>
<td>
<form action="product_rate.php" method="post">
<input type="hidden" name="topic" value="<?php echo $statement['topic'];?>" />
<input type="submit" value="Downvote" name="action"/>
</form>
</td>
</tr>
<?php endforeach; ?>