'. stripslashes($row['post_title']).'
'); if ($story == 1) { echo(stripslashes($row['content']).'
'); } else if ($story == 2) { echo(stripslashes($row['content']).'...
'); } } } /** random_post_by_category() ** as above but random rather than latest **/ function random_post_by_category($cat=1, $story=0) { global $tableposts; if ($story == 1) { $post_amount = ', post_content AS content'; } else if ($story == 2) { $post_amount = ', SUBSTRING(post_content, 1, 80) AS content'; } else { $post_amount = ''; } $date_format = '%d/%m/%y %h:%i'; // See http://www.mysql.com/doc/en/Date_and_time_functions.html for full spec $sql= " SELECT ID, post_title, DATE_FORMAT(post_date, '%d/%m/%y %h:%i') AS formatted_date " . " $post_amount " . " FROM $tableposts " . " WHERE post_category = $cat " . " ORDER BY RAND() LIMIT 1"; $result=mysql_query($sql); if ($row = mysql_fetch_array($result)) { echo($row['formatted_date'].'
'. stripslashes($row['post_title']).'
'); if ($story == 1) { echo(stripslashes($row['content']).'
'); } else if ($story == 2) { echo(stripslashes($row['content']).'...
'); } } } /* Example use: This line can go anywhere after php $blog=1 include("blog.header.php"); in your main blog page (index.php) which is on the first line. include_once('latest_post.php'); Then put one of these where you want the link/story to appear: latest_post_by_category(3); // category 3 no 'content' latest_post_by_category(3, 2); // category 3 first 80 chars latest_post_by_category(2, 1); // category 2 full 'content' as above but random random_post_by_category(2); random_post_by_category(2, 2); random_post_by_category(2, 1); each of these needs to be inside a < ? php ? > block */ ?>