Hey there. I'm currently trying to convert my old html site into a PHP/mysql driven site. So far so good. I can get all the files of certain types to print just great.
The problem I'm having is that I can't seem to figure out a way to display files that are only a month old in a different fashion from those that are older (I want to have a "current" content section and a "not so current" section).
I have entered the dates into the mysql database as timestamps. I am not sure if that was a good idea or not. If that is the problem, I'm not at a point where it would be too hurful to have to rebuild the database.
Maybe this isn't even possible? Any help would be appreciated. I included
Below is how I'm currently trying to accomplish this. I might be way off (or too ambitious), so if there's an easier method than what I'm trying I'd be glad to hear it.
<?php
$yr = date("Y");
$mn = date("m");
$dy = date("d");
$offset = -1;
$offset2 = 0;
$oldday = strftime("%Y-%m-%d",
mktime(0,0,0,$mn,$dy,$yr));
$newday = strftime("%Y-%m-%d",
mktime(0,0,0,$mn+$offset2,$dy+$offset,$yr));
include ('../../motards.inc.php');
$connection = mysql_connect($server,$user,$pass) or
die ("the connection didn't work");
@mysql_select_db($db) or die ("the database wasn't found, sorry");
?>
<?php
include ('pichead.inc.php');
?>
<ul>
<?php
$result = mysql_query("select
id,type,filename,pagetitle,seriesnum,author, Unix_Timestamp(pagedate) as Formated_Time
from files where TYPE='pics'", $connection) or die ("error in result");
while (list($id,$type,$filename,$pagetitle,$seriesnum,$author,$pagedate) = mysql_fetch_row($result))
{
if ($pagedate <= $newday)
{
if ($filename != "index.php")
{
echo "<li><a href=$filename class=newish>$pagetitle</a>";
}
}
elseif ($pagedate >= $newday)
{
if ($filename != "index.php")
{
echo "<li><a href=$filename>$pagetitle</a>";
}
}
}
mysql_close();
?>
</ul>
</body>
</html>