I am trying to make a blog archive unordered list that automatically adds dates from the database
Here's the database code
blogARCHIVEDATE is formatted like 200809 for September 2008
The database code works, it's an issue with the php code
CODE
$query_archiveDATE = "SELECT DISTINCT blogARCHIVEDATE FROM blog ORDER BY blogARCHIVEDATE DESC";
$archiveDATE = mysql_query($query_archiveDATE, $daveCONN);
$row_archiveDATE = mysql_fetch_assoc($archiveDATE);
Here's the php code, i know it's crazy and I could figure out a better way to do the month names instead of a huge elseif statement. I am new, I just kinda started writing the code hoping I could get it to work. Anyways when i preview in the browser, it's just a blank screen.
CODE
<ul>
<?php do { ?>
<?php
$year = substr($row_archiveDATE['blogARCHIVEDATE'], 0, 4);
$month = substr($row_archiveDATE['blogARCHIVEDATE'], 4, 2);
if $month = 01{
$monthname = "January";
} elseif $month = 02 {
$monthname = "February";
} elseif $month = 03 {
$monthname = "March";
} elseif $month = 04 {
$monthname = "April";
} elseif $month = 05 {
$monthname = "May";
} elseif $month = 06 {
$monthname = "June";
} elseif $month = 07 {
$monthname = "July";
} elseif $month = 08 {
$monthname = "August";
} elseif $month = 09 {
$monthname = "September";
} elseif $month = 10 {
$monthname = "October";
} elseif $month = 11 {
$monthname = "November";
} elseif $month = 12 {
$monthname = "December";
?>
<?php
if ($month < 10) {
$month = substr($month,1,1);
} else {
$month=$month;
}
?>
<li><a href=<?php echo "blog.php?bm=".$month."&by=".$year; ?>><?php echo $monthname." ".$year; ?> </a></li>
<?php } while ($row_archiveDATE = mysql_fetch_assoc($archiveDATE)); ?>
</ul>
The reason for <?php if $month < 10 ? substr($month,1,1) : $month=$month; ?> is because in the database the monts are single digits (except oct-dec obviously) instead of a 0.
Thanks,
Steve