Help with sorting something
Posted: Sat Sep 03, 2005 3:19 pm
hey i'm just making a comment board heres the function that displays the old entries:
what i want it to do is sort by variable, $date but can't figure out how
thanks in advanced
Code: Select all
function showold($file,$badwordsarray,$cleanword) {
switch($_GET[badlang]) {
case off:
$filter = 0;
break;
default:
$filter = 1;
break;
}
$contents_old = file_get_contents($file);
if($filter) {
echo "<font class='valid'>bad words filter is ON. click <a href='?badlang=off'>here</a> to turn it off</font>";
$contents_old = str_ireplace($badwordsarray,$cleanword,$contents_old);
} else {
echo "<font class='invalid'>bad words filter is OFF! click <a href='index.php'>here</a> to turn it on</font>";
}
$row = explode("|line|",$contents_old);
?>
<table class="old">
<?php
for($i = 0;$i < count($row);$i++)
{
list($name,$contact,$subject,$date,$comment) = explode("|#|",$row[$i]);
$color1 = "#DDDDDD";
$color2 = "#EEEEEE";
$style = ($i % 2==1) ? "$color1" : "$color2";
echo '
<tr>
<td rowspan="2" class="leftold" title="Post #'.$i.'">'.$i.'</td>
<td rowspan="2" class="leftold" ><font title="Poster\'s Name">'.$name.'</font><br>[ <font class="oldleft" title="Email/Sn of '.$name.'">'.$contact.'</font> ]</td>
<td class="rightold" title="Subject of Post"><b>Subject:</b><i>'.$subject.'</i></td>
<td class="rightold" title="Date/Time Posted"><b>Date/Time:</b><i>'.$date.'</i></td>
</tr>
<tr>
<td class="rightold" style="background-color:#EEEEEE" colspan=2 title="'.$name.'\'s Comment">'.$comment.'</td>
</tr>
';
}
echo '</table>';
}thanks in advanced