I have the field date
in my MySQL DB as a string, and I want to compare it to another string in a MySQL query to get the recent activity for a user within a week. But for some reason I am getting no returned data from the fetch_assocs.
Please can you tell me where I am going wrong?
$week = uk_date();
echo $week . " - ---------- -";
$week = $week - (60*24*7);
echo $week;
$array = array();
$q = mysql_query("SELECT * FROM Posts WHERE `date` > " . $week . "") or die(mysql_error());
if (!$q) {}
if (mysql_num_rows($q) < 1) {
}
else {
while ($row = mysql_fetch_assoc($q)) {
$array['posts'][] = $row;
}
}
$q = mysql_query("SELECT * FROM Comments WHERE `date` > " . $week . "") or die(mysql_error());
if (mysql_num_rows($q) < 1) {
}
else {
while ($row = mysql_fetch_assoc($q)) {
$array['comments'][] = $row;
}
}
$q = mysql_query("SELECT * FROM Likes WHERE `date` > " . $week . "") or die(mysql_error());
if (mysql_num_rows($q) < 1) {
}
else {
while ($row = mysql_fetch_assoc($q)) {
$array['likes'][] = $row;
}
}