-----CODE-----
$today = date("Ymd");
$thisday = date("d");
$thisday = $thisday -7;
$thismonth = date("m");
$thisyear = date("Y");
$week = date("Ymd", mktime(0,0,0,$thismonth, $thisday,$thisyear));
$query = "SELECT * FROM news order by NUMER_DATE DESC;";
$mysql_result = mysql_query($query,$mysql_link);
while ($row = mysql_fetch_row($mysql_result))
{
if ($row[7] >= $week && $row[7] <= $today)
print("<A HREF='index.php?action=viewrec&rec=$row[0]'>$row[1]</A> (<i>$row[2]</i>)<br>");
}
-----/CODE-----
The above does NOT work. numer_date (row[7]) is a numerical representation of the date the news was posted. e.g. 200105181423 (year, month, day, military hour, minute).
-----CODE-----
$query = "SELECT * FROM news WHERE NUMER_DATE >= $week AND NUMER_DATE <= $today order by NUMER_DATE DESC;";
-----/CODE-----
This is the other (simpler) query I tried, but that returns an empty set, also. The query above is the only thing (except for the if-then) that changed between the CODE blocks.
When I go through telnet and type
select numer_date from news;
into MySQL, I get all of the results (just like I wanted)
+--------------+
| numer_date |
+--------------+
| 200104211208 |
| 200104211445 |
| 200104222222 |
| 200104222231 |
| 200104250142 |
| 200104261442 |
| 200104270053 |
| 200104271208 |
| 200104270053 |
| 200104271208 |
| 200104271453 |
| 200104281154 |
| 200104281631 |
| 200104292310 |
| 200105011614 |
| 200105020300 |
| 200105021605 |
| 200105041605 |
| 200105050659 |
| 200105132242 |
| 200105162237 |
| 200105171045 |
| 200105171621 |
| 200105181326 |
| 200105181726 |
+--------------+
23 rows in set (0.00 sec)
Now... the question is... why won't this work if I use the code you provided?
I checked to see what values \$today and \$week have, and they have the correct values.