Tilted Forum Project Discussion Community  

Go Back   Tilted Forum Project Discussion Community > Interests > Tilted Technology


 
 
LinkBack Thread Tools
Old 09-08-2004, 04:34 PM   #1 (permalink)
Psycho
 
FaderMonkey's Avatar
 
Location: Orlando, FL
[PHP/MySQL] monthly archives

I have a blog and I want to setup archive links for my entries split up by month. My first thought on how to do this would be to use an IF condition with my date timestamp for each entry, but I'm using a DATE_FORMAT function in my query to format the date like this:

PHP Code:
$query ="SELECT entryid, entrytext,";
$query.=" DATE_FORMAT(entrydate, '%M %d, %Y %T') AS date";
$query.=" FROM blog ORDER BY entryid DESC LIMIT 10";
$result=mysql_query($query); 
How ideas on how best to go about setting this up?
FaderMonkey is offline  
Old 09-09-2004, 04:40 AM   #2 (permalink)
Upright
 
Well, there is no "IF" in SQL, just WHERE...

Aren't you just wanting a WHERE clause like:

WHERE entrydate>'somedate' AND entrydate<'someotherdate'
bacon is offline  
Old 09-09-2004, 06:23 AM   #3 (permalink)
Insane
 
Location: Wales, UK, Europe, Earth, Milky Way, Universe
Not quite sure what you're trying to do but maybe something like:

PHP Code:
$query ="SELECT entryid, entrytext,";
$query.=" DATE_FORMAT(entrydate, '%M %d, %Y %T') AS date";
$query.=" FROM blog ORDER BY entrydate DESC LIMIT 10";
$query.=" WHERE MONTHNAME(date) = '$required_month'";
$result=mysql_query($query); 
Is that what you were getting at?
__________________
There are only two industries that refer to their customers as "users". - Edward Tufte

Last edited by welshbyte; 09-09-2004 at 07:05 AM.. Reason: Didnt understand the question the first time!
welshbyte is offline  
Old 09-09-2004, 07:59 AM   #4 (permalink)
Psycho
 
FaderMonkey's Avatar
 
Location: Orlando, FL
Quote:
Originally Posted by bacon
Well, there is no "IF" in SQL, just WHERE...

Aren't you just wanting a WHERE clause like:

WHERE entrydate>'somedate' AND entrydate<'someotherdate'
I assumed that because I'm using the DATE_FORMAT fuction that I wouldn't be able to do it that way, but you're right, it works.

Thanks!
FaderMonkey is offline  
Old 09-18-2004, 07:38 PM   #5 (permalink)
Upright
 
u know... what you could try is installing phpmyadmin


then do queries with the script until it gives back the results u want and have it convert the query to php and walah... u have ur querey ready togo
zigx is offline  
 

Tags
archives, monthly, php or mysql


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -8. The time now is 06:38 AM.

Tilted Forum Project

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
Search Engine Optimization by vBSEO 3.6.0 PL2
© 2002-2012 Tilted Forum Project

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73