Vote count:
0
So on my project I have posts. And basically they include the post time and post content. Now here's my issue, I can only figure out how to retrieve one row instead of post content and post time. Here's my code
$posts = array();
while($row = $stmt->fetch(PDO::FETCH_ASSOC)){
$posts[] = $row['post_content'];
}
And how I'm returning
<?php
foreach($posts as $post) {
$post;
?>
<div class="content">
<div class="post">
<h1 class="message">
<?php
echo $post;
?>
</h1>
<p class="time">4 minutes ago</p>
</div>
</div>
<?php
}
?>
I've tried
$posts = array();
$time = array();
while($row = $stmt->fetch(PDO::FETCH_ASSOC)){
$posts[] = $row['post_content'];
$time[] = $row['post_time'];
}
But that doesn't work. I've ran out of ideas. Any help would be great. Also if there is a cleaner way to do this, it would be nice knowing how. Thanks
asked 1 min ago
Aucun commentaire:
Enregistrer un commentaire