hi !
how to creat list or dropdown menu list for monthly archives using php/mysql ?
EXAMPLE :
MARCH 2008
FEBRUARY 2008
APRIL 2008
MAY 2008
.
.
.
.
................
Now if any month not have data . NOTE : not show in list .
thanks regards
hi !
how to creat list or dropdown menu list for monthly archives using php/mysql ?
EXAMPLE :
MARCH 2008
FEBRUARY 2008
APRIL 2008
MAY 2008
.
.
.
.
................
Now if any month not have data . NOTE : not show in list .
thanks regards
We'd have to see a whole structure. But if you have a timestamp date in your database that either uses the number of the month( 1-12 ), the name of the month ( Jan - Dec ), or a time stamp ( time() ), you could do this.
Can you please tell me what your using first though?
-Nile
Jeremy | jfein.net
yes , save in tiemstamp method .
Try this(change all the table names & fields to your database and tables).
Code:<?php if(isset($_GET['arch'])){connect(); //connect to your database and host$result = mysql_query("SELECT * FROM `table_name`") or die(mysql_error()); while($row = mysql_fetch_assoc($result)){ if((date("m", $row['timestamp']) == $_GET['arch'])){ echo $row['what_to_display']; } } exit; } $months = range(1, 12); foreach($months as $month){ echo "<a href='?arch=".date("m", mktime(0,0,0,$month))."'>".date("F", mktime(0,0,0,$month))."<br />"; } ?>
Last edited by Nile; 02-10-2009 at 11:20 PM.
Jeremy | jfein.net
this code list all month in database . without year !!!!!Code:<?php if(isset($_GET['arch'])){ connect(); //connect to your database and host $result = mysql_query("SELECT * FROM `table_name`") or die(mysql_error()); while($row = mysql_fetch_assoc($result)){ if((date("m", $row['timestamp']) == $_GET['arch'])){ echo $row['what_to_display']; } } exit; } $months = range(1, 12); foreach($months as $month){ echo "<a href='?arch=".date("m", mktime(0,0,0,$month))."'>".date("F", mktime(0,0,0,$month))."<br />"; } ?>
how to show ONLY month which have data + year
EXAMPLE :
month 1 2008 / month 2 2008 / month 4 2008 / month 7 2008 . . . . . . .
NOTE : month 3 , 5 & 6 not have data so not show in list .
Bookmarks