Might someone please tell me how to have this form sort just the opposite that it does right now. It now sorts from earliest date to latest date,, I would like it to sort newest post first. Thanks!!
I have to do this in 2 parts as its to long, sorry
<html>
<head>
<title></title>
</head>
<body bgcolor="#E8E6B5" text="#E8E6B5">
<?php
include_once('func.php');
session_start();
if (!isset($_SESSION['access'])) { $_SESSION['access'] == false; }
$password = 'th123';
$form1 = 'form.txt';
$main_script = 'form.php'; // This should be http path to script.
loadfile();
function loadfile() {
// LOAD DATA
global $form1;
global $main1;
global $main2;
global $main3;
global $main4;
global $main5;
$main1 = array(); // Name
$main2 = array(); // Location
$main3 = array(); // Date
$main4 = array(); // Web
$main5 = array(); // Desc
if(file_exists($form1)) {
$tmp = file($form1);
$x = 0;
foreach($tmp as $element) {
$data = split("\|msg\|", trim($element));
$main1[$x] = $data[0];
$main2[$x] = $data[1];
$main3[$x] = $data[2];
$main4[$x] = $data[3];
$main5[$x] = $data[4];
$x++;
}
} else {
print "<H4>Cannot find $form1</H4>";
}
}
function savetofile() {
// SAVE DATA
global $form1;
global $main1;
global $main2;
global $main3;
global $main4;
global $main5;
uasort($main3,'DateCmp');
$fp = fopen($form1, "w");
if (isset($main3)) {
foreach($main3 as $key => $value)
{
fwrite($fp,stripslashes($main1[$key]) . '|msg|' . stripslashes($main2[$key]) . '|msg|' . stripslashes($main3[$key]) . '|msg|' . stripslashes($main4[$key]) . '|msg|' . stripslashes($main5[$key]) . "\r\n");
}
}
fclose($fp);
loadfile();
}
?>
<div align="center">
<center>
<table border="0" cellpadding="0" cellspacing="">
<tr>
<td width="100%" bgcolor="#E8E6B5">
<table cellSpacing="0" cellPadding="0" bgColor="#E8E6B5" border="0" width="100%">
<tbody>
<tr>
<td valign="top" align="center" bgcolor="#E8E6B5">
<table cellSpacing="0" cellPadding="0" width="100%" border="0">
<tbody>
<tr>
<td vAlign="top" align="left" width="45"></td>
<td vAlign="center" align="left" width="100%" height="29" bgcolor="#E8E6B5"><font color="#FF9900"><strong>
Admin Page</strong></font></td>
<td vAlign="top" align="left" width="45"></td>
</tr>
</tbody>
</table>
<table cellSpacing="0" cellPadding="0" width="100%" border="0">
<tbody>
<tr>
<td bgcolor="#E8E6B5">
<table cellSpacing="0" cellPadding="0" width="100%" border="0">
<tbody>
<tr>
<td vAlign="top" align="left" width="45" bgcolor="#E8E6B5"></td>
<td bgcolor="#E8E6B5">
<table cellSpacing="0" cellPadding="0" width="100%" border="0" bgcolor="#f3f3f3">
<tbody>
<tr vAlign="top">
<td bgcolor="#E8E6B5">
<br />
<div align="right"><script>
var mydate=new Date()
var year=mydate.getYear()
if (year < 1000)
year+=1900
var day=mydate.getDay()
var month=mydate.getMonth()
var daym=mydate.getDate()
if (daym<10)
daym="0"+daym
var dayarray=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
var montharray=new Array("January","February","March","April","May"," June","July","August","September","October","November","December")
document.write("<font color='FF0000' face='Verdana' <font size='0'><b>"+dayarray[day]+", "+montharray[month]+" "+daym+"</b></font></small>")
</script></div>
<br />
<?php
// PROCES ACTIONS
if($_SERVER['REQUEST_METHOD'] == 'POST')
{
$action = $_POST['action'];
switch($action) {
case "Add":
if($_POST['name'] != "" && $_POST['value'] != "" && $_POST['date'] != '') {
$x = count($main1);
$main1[$x] = $_POST['name'];
$main2[$x] = $_POST['location'];
$main3[$x] = $_POST['date'];
$main4[$x] = $_POST['web'];
$main5[$x] = str_replace(chr(10),"",str_replace(chr(13),'<br>',$_POST['value']));
savetofile();
}
?>
<script type="text/javascript">
document.location.href = "<?php echo $main_script; ?>";
</script>
<?php