I am trying to compare a string that i send a script to a datetime column type.. here is my script
so as you can see.. i pass the script a var with a value of six chars. ex: 032005.. then i break it up into month and year.. and convert that to : 2005-03-00 00:00:00 . and i want to compare that to the post_date column in the db.. i was attempting to use the unix_timestamp function but not any luck. so anyway that i can compare dates would be greatPHP Code:<?php
require("config.php");
$catId = $_REQUEST['catId'];
//make date to get
$date = $_REQUEST['date'];
$month = substr($date,0,2);
$year = substr($date,2,4);
$getDate = $year . "-" . $month . "-00 00:00:00";
echo $getDate;
//connect to db
$link_id = db_connect();
//query db for article
$query = "
SELECT wp_posts.ID as postId,
unix_timestamp(wp_posts.post_date) as postUnixDate,
date_format(wp_posts.post_date,'%Y %M %D') as postDate,
wp_posts.post_title as postTitle,
wp_categories.cat_name as categoryName,
wp_categories.cat_ID as categoryId
FROM wp_posts
INNER JOIN wp_post2cat ON wp_posts.ID = wp_post2cat.post_id
INNER JOIN wp_categories ON wp_post2cat.category_id = wp_categories.cat_id
//compare dates
AND wp_posts.post_date < unix_timestamp('$getDate')
//------
AND wp_categories.cat_ID = '$catId'
ORDER BY wp_posts.post_date DESC";
$result = mysql_query($query);
$count = 0;
while($thisPost = mysql_fetch_array($result)){
$values .= "&pId$count=" . $thisPost['postId'] . "&date$count=" . $thisPost['postDate'] .
"&cId$count=" . $thisPost['categoryId'] . "&cName$count=" . $thisPost['categoryName'] .
"&t$count=" . $thisPost['postTitle'];
$count++;
}
$returnValue = "&count=$count" . $values;
echo $returnValue;
?>
can someone help??
thankx all





Bookmarks