View unanswered posts | View active topics It is currently Wed Aug 17, 2022 4:36 pm

Reply to topic  [ 2 posts ] 
 bad WHERE clause? 
Author Message
Junior Member

Joined: Tue May 04, 2004 5:08 pm
Posts: 2
have a table (NewsArchives) with the following fields:

ID, date, sort, title, description

Each month we add anywhere from 10-15 articles to the database. On the page
where we keep the current month's articles, we would like to filter the
record set by saying.....please show only the records with the most recent
date in the date field, if you come across something with and earlier date,
don't show it.

For example, we just added 13 articles for May, so we only want those 13
articles on the current page....all the articles from April and before won't
show up.

Currently, here is my record set code:
mysql_select_db($database_jpike, $jpike);
$query_rsENews = 'SELECT * FROM NewsArchive WHERE YEAR(date) = ' . date('Y')
. ' AND MONTH(date) = ' . date('m') . ' ORDER BY sort DESC';
$rsENews = mysql_query($query_rsENews, $jpike) or die(mysql_error());
$row_rsENews = mysql_fetch_assoc($rsENews);
$totalRows_rsENews = mysql_num_rows($rsENews);

what is happening is that the page is returning NO data at all, but there is
no error message either.....

when i take out the WHERE clause I DO get data returned....every record in the table....

any ideas? thanks a million

Tue May 04, 2004 5:09 pm
Report this post
Junior Member

Joined: Tue May 11, 2004 1:23 am
Posts: 1
for the month try date('n') -> returns the month witout leading 0
for the year try date('y') -> returns the year with four digits...

try to look this stuff up in the mysql and php documentation... this should clear things up...

Tue May 11, 2004 1:55 am
Report this post
Display posts from previous:  Sort by  
Reply to topic   [ 2 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
© Copyright 2003-2008 The ultimate PHP Editor and PHP IDE site.