[php]

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
” . $newest[‘post_title’] .”
This post was created on ” . $newest[‘post_date’]. “
” . $newest[‘post_content’] . “

Click here to see original post

Random Lost and Found Ad

” . $random[‘header’] .”
Posted to ” . $random[‘site’] . ” on ” . $random[‘date’]. “
” . $data .”

Click here to see original post

“;

[/php]
PetHoot - Happy Pet Makes Happier Owner
Use the social icons below posts and share with your friends.
Help a LOST and a FOUND become a REUNITED.
There's now a third option for high-speed Internet in Louisville
HELP LLAF
GROW & IMPROVE
DONATE HERE
Thank You!
THINK YOU HAVE THE CUTEST PET?
Post a pic on
I'd Pet That
and see how your
pet ranks.
petlogo

+ SLOW PC? +

Limited Time Offer
FREE PC TUNE-UPS
IgLou Onsite

Find out more here.

shadow-line