Pennimus
02-14-2006, 09:58 PM
I'm constructing a blog for my site. After I got nowhere trying to automatically configure dd-mm-yyyy dates on the fly, I decided just to write the dates manually and order the posts by automatically incremented id instead.
However, in constructing my monthly archive pages I've come up against a problem. Here is the PHP I'm using to get the info from the database:
$blog = mysql_query ("SELECT title, content, date FROM blog WHERE date IN ('August 2005') ORDER BY id DESC LIMIT 10") or die(mysql_error());
The date column in my table is VARCHAR and all the entries so far contain the characters August 2005 but all I get is a blank page. I'm using this while loop to display the results:
while ($entry = mysql_fetch_array($blog)){
echo '
<p class="blogdate">
'. $entry['date'] .'
</p>
<h2>'. $entry['title'] .'</h2>
<div class="blog">
'. $entry['content'] .'
</div>
';
}
Both elements work fine when I remove the WHERE/IN part of the query. Can anybody see where I've gone wrong?
- Adam
However, in constructing my monthly archive pages I've come up against a problem. Here is the PHP I'm using to get the info from the database:
$blog = mysql_query ("SELECT title, content, date FROM blog WHERE date IN ('August 2005') ORDER BY id DESC LIMIT 10") or die(mysql_error());
The date column in my table is VARCHAR and all the entries so far contain the characters August 2005 but all I get is a blank page. I'm using this while loop to display the results:
while ($entry = mysql_fetch_array($blog)){
echo '
<p class="blogdate">
'. $entry['date'] .'
</p>
<h2>'. $entry['title'] .'</h2>
<div class="blog">
'. $entry['content'] .'
</div>
';
}
Both elements work fine when I remove the WHERE/IN part of the query. Can anybody see where I've gone wrong?
- Adam