I am using the following code to generate a list of 6 random entries from the whole weblog:
CODE
<?php
$database = "mt_db";
$db = mysql_connect("localhost", "user", "pw") or die ("Unable to connect to MySQL server.");
mysql_select_db("$database",$db) or die ("Unable to select requested database.");
// define blog url
$blogurl="http://www.offroadpakistan.com/pictures";
// dirify function to create links to archives
// that use archive file templates for naming
function dirify ($s) {
$s = strtolower($s);
$patterns = array('/<[\/\!]*?[^<>]*?>/s', '/&[^;\s]+;/',
'/[^\w\s]/', '/ /');
$replace = array('', '', '', '_');
$s = preg_replace($patterns, $replace, $s);
return $s;
}
// set the limit to how many you want to show
$random = "SELECT e.entry_title, e.entry_text, e.entry_id, e.entry_text_more, date_format(e.entry_created_on, '%M %d, %Y') AS readable_date, c.category_label FROM mt_entry e, mt_placement p, mt_category c WHERE (e.entry_id = p.placement_entry_id) and (p.placement_category_id = c.category_id) and (e.entry_blog_id=4) and (e.entry_status=2) and (p.placement_is_primary=1) ORDER by rand() LIMIT 6";
$result = mysql_query($random);
while ($row = mysql_fetch_array($result)) {
$cat = dirify ($row['category_label']);
$cat1 = $row['category_label'];
$title = $row['entry_title'];
$title = str_replace(" |", "", $title);
$title = dirify ($title);
$title1 = $row['entry_title'];
$entryid = $row['entry_id'];
$dater = $row['readable_date'];
$entrytext = $row['entry_text'];
$location = $row['entry_text_more'];
$addthumb='-thumb.jpg';
$imgsize = GetImageSize ("$location.jpg",$info );
echo "<a href=\"$blogurl/$cat/$title$entryid.php\"> <img src=\"$location$addthumb\" width=\"120\" height=\"90\" alt=\"$title1\" title=\"$title1\"></a>";
}
mysql_free_result($result);
?>
$database = "mt_db";
$db = mysql_connect("localhost", "user", "pw") or die ("Unable to connect to MySQL server.");
mysql_select_db("$database",$db) or die ("Unable to select requested database.");
// define blog url
$blogurl="http://www.offroadpakistan.com/pictures";
// dirify function to create links to archives
// that use archive file templates for naming
function dirify ($s) {
$s = strtolower($s);
$patterns = array('/<[\/\!]*?[^<>]*?>/s', '/&[^;\s]+;/',
'/[^\w\s]/', '/ /');
$replace = array('', '', '', '_');
$s = preg_replace($patterns, $replace, $s);
return $s;
}
// set the limit to how many you want to show
$random = "SELECT e.entry_title, e.entry_text, e.entry_id, e.entry_text_more, date_format(e.entry_created_on, '%M %d, %Y') AS readable_date, c.category_label FROM mt_entry e, mt_placement p, mt_category c WHERE (e.entry_id = p.placement_entry_id) and (p.placement_category_id = c.category_id) and (e.entry_blog_id=4) and (e.entry_status=2) and (p.placement_is_primary=1) ORDER by rand() LIMIT 6";
$result = mysql_query($random);
while ($row = mysql_fetch_array($result)) {
$cat = dirify ($row['category_label']);
$cat1 = $row['category_label'];
$title = $row['entry_title'];
$title = str_replace(" |", "", $title);
$title = dirify ($title);
$title1 = $row['entry_title'];
$entryid = $row['entry_id'];
$dater = $row['readable_date'];
$entrytext = $row['entry_text'];
$location = $row['entry_text_more'];
$addthumb='-thumb.jpg';
$imgsize = GetImageSize ("$location.jpg",$info );
echo "<a href=\"$blogurl/$cat/$title$entryid.php\"> <img src=\"$location$addthumb\" width=\"120\" height=\"90\" alt=\"$title1\" title=\"$title1\"></a>";
}
mysql_free_result($result);
?>
If I have the entry-id, how can I call one specific post?