I'm just wondering if its possible to combine a "blog tutorial"-lookalike, and the basic template system from the tutorial?
I get things working, but as soon as I start getting data from the database in the home.page.inc.php file, nothing is listed.
This is what my home.page.inc.php file looks like.
<?php $posts = get_posts(); foreach ($posts as $post){ ?> <div class="post"> <p class="meta"><span class="date"><?php echo $post['date']; ?></span><a href="?page=users&id=<?php echo $post['user_id']; ?>"> <?php echo $post['user']; ?></a></p> <h2 class="title"><a href="?page=read&id=<?php echo $post['post_id']; ?>"><?php echo $post['title']; ?></a></h2> <div class="entry"> <p><?php echo $post['preview']; ?></p> <a href="?page=read&id=<?php echo $post['post_id']; ?>" class="links">Les mer..</a> </div> </div> <?php } ?>And this is my posts.inc.php
function get_posts(){ $sql = "SELECT `postdata`.`post_id`, `postdata`.`post_title`, LEFT(`postdata`.`post_body`, 512), DATE_FORMAT(`postdata`.`post_date`, '%d.%m.%Y - %h:%i:%s'), `postdata`.`user_id`, `userdata`.`user_id`, `userdata`.`username` FROM `postdata` INNER JOIN `userdata` ON `postdata`.`user_id` = `userdata`.`user_id` ORDER BY `postdata`.`post_date` DESC "; $posts = mysql_query($sql); $rows = array(); While (($row = mysql_fetch_assoc($posts)) !== false){ $rows[] = array( 'post_id' => $row['post_id'], 'title' => $row['post_title'], 'preview' => $row['post_body'], 'user' => $row['username'], 'date' => $row['post_date'], 'user_id' => $row['user_id'], ); } return $rows; }