include(‘sites/functions.php’);
dbConnect();
global $count;
function getLatestWP($count){
$query_wp = mysql_query(“SELECT `ID` FROM `wp_posts` WHERE `post_status`=’publish’ ORDER BY post_date DESC LIMIT 1”) or die(mysql_error());
$newpost = mysql_fetch_row($query_wp);
if($count > 0) $newpost[0] = $newpost[0] – $count;
$pic_q = mysql_query(“SELECT `guid` FROM `wp_posts` WHERE `post_type`=’attachment’ AND `post_parent`=’$newpost[0]'”)or die(mysql_error());
$picture = mysql_fetch_row($pic_q);
$newpost[1] = $picture[0];
if($newpost[1]) return($newpost);
else return false;
}
function getLatestPost($newpost){
$results = mysql_fetch_array(mysql_query(“SELECT * FROM `wp_posts` WHERE id=’$newpost[0]'”));
return $results;
}
function getRandomPost($start, $end){
$id = rand($start[0], $end[0]);
$results = mysql_fetch_array(mysql_query(“SELECT * FROM `sites` WHERE id=’$id'”));
return $results;
}
$total_posts = 0;
$postid = array();
$squery = mysql_query(“SELECT `id` FROM `sites` ORDER BY `id` ASC LIMIT 1”) or die(mysql_error());
$start = mysql_fetch_row($squery);
$equery = mysql_query(“SELECT `id` FROM `sites` ORDER BY `id` DESC LIMIT 1”) or die(mysql_error());
$end = mysql_fetch_row($equery);
do{ $newpost = getLatestWP($count);
$count++;
} while ($newpost[1] == null);
$newest = getLatestPost($newpost);
do{ $random = getRandomPost($start, $end);
} while($random[‘imageurl’] == null);
$data = preg_replace(“/
/”,””,$random[‘data’]);
echo ”
Latest Post to Louisville Lost and Found | ||||||
|
||||||
| ||
|
“;
[/php]