Tilted Forum Project Discussion Community

Tilted Forum Project Discussion Community (https://thetfp.com/tfp/)
-   Tilted Technology (https://thetfp.com/tfp/tilted-technology/)
-   -   [PHP/MySQL] monthly archives (https://thetfp.com/tfp/tilted-technology/68425-php-mysql-monthly-archives.html)

FaderMonkey 09-08-2004 04:34 PM

[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? :confused:

bacon 09-09-2004 04:40 AM

Well, there is no "IF" in SQL, just WHERE...

Aren't you just wanting a WHERE clause like:

WHERE entrydate>'somedate' AND entrydate<'someotherdate'

welshbyte 09-09-2004 06:23 AM

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?

FaderMonkey 09-09-2004 07:59 AM

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!

zigx 09-18-2004 07:38 PM

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


All times are GMT -8. The time now is 12:51 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2026, 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