Sorting I guess

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
wesnoel
Forum Commoner
Posts: 58
Joined: Fri Sep 05, 2003 11:53 am

Sorting I guess

Post by wesnoel »

Well this is what I have so far.



Code: Select all

<html>

	<head>
		<meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
		<meta name="generator" content="Adobe GoLive 6">
		<title>Merchant Verification System</title>
		
		
		

 
 <STYLE>
 
  body { 
                margin: 6pt; 
		  color: #003366; 
		  font-family: arial;
		   font-size: 9px;
	     }     
 input { 
            border: 1px solid #ffffff;
            font-family: verdana;
            color: #003366;
            font-size: 11px; 
            }   
            
.edit { 
            border: 1px solid #003366;
            font-family: verdana;
            color: #FF0033;
            font-size: 11px; 
            }       
            
.date { 
            font-family: verdana;
            color: #F999999;
            font-size: 9px; 
            }                    
            
            
  }
 </STYLE>
		<csscriptdict import>
			<script type="text/javascript" src="file:///C:/Documents%20and%20Settings/wnoel/Application%20Data/Adobe/Adobe%20GoLive/Settings/JScripts/GlobalScripts/CSScriptLib.js"></script>
		</csscriptdict>
		<csactiondict>
			<script type="text/javascript"><!--
var preloadFlag = false;
function preloadImages() {
	if (document.images) {
		over_REFRESH_01 = newImage(/*URL*/'images/REFRESH_01-over.gif');
		preloadFlag = true;
	}
}

// --></script>
		</csactiondict>
		<SCRIPT LANGUAGE="JavaScript">
function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=710,height=580,left = 10,top = 10');");
}
</script>

<SCRIPT LANGUAGE="JavaScript">
function popUp2(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=710,height=580,left = 10,top = 10');");
}
</script>


		
	</head>

	<body onload="preloadImages();" bgcolor="#ffffff" link="#003366" vlink="#003366" alink="#aaaaaa" leftmargin="0" marginheight="0" marginwidth="0" topmargin="0">
		<table width="80%" border="0" cellspacing="0" cellpadding="0" bgcolor="#003366">
			<tr>
				<td width="566"><b><font size="+1" color="white">&nbsp;&nbsp;</font><font size="+2" color="white">Merchant Verification System  </font></b></td>
				<td><font size="1" face="Verdana">[ </font></td>
			</tr>
			<tr>
				<td bgcolor="white" width="566">&nbsp;</td>
				<td bgcolor="white"></td>
			</tr>
			<tr>
				<td bgcolor="white" width="566"><font size="1" face="Verdana"><b><a onmouseover="changeImages( /*CMP*/'REFRESH_01',/*URL*/'images/REFRESH_01-over.gif');return true" onmouseout="changeImages( /*CMP*/'REFRESH_01',/*URL*/'images/REFRESH_01.gif');return true" href="list.php"><img src="images/REFRESH_01.gif" alt="" name="REFRESH_01" height="16" width="92" border="0"></a><br>
							<br>
						</b></font></td>
				<td bgcolor="white"></td>
			</tr>
		</table>
		<table width="80%" border="0" cellspacing="0" cellpadding="0" bgcolor="#003366">
			<tr>
				<td><font size="2" color="white"><b>&nbsp;&nbsp;Current Verification Requests</b></font></td>
			</tr>
		</table>
	</body>
</html>



<?php

// Delete function

$del = $_GET['del'];
if(isset($del)){
unlink("$del");
}


// File array start

$files = array();

// Root directory to the files below 
$files_directory = "files";

echo "<br><table width="60%" border="0" cellspacing="0" cellpadding="1">";

$fdirectory = opendir( "$files_directory" );
while ($file = readdir( $fdirectory ) ) {
if ( ( $file == "." ) || ( $file == ".." ) ) {
    } else {
    array_push( $files, $file );
    }
}

$file_array = array_reverse ($files, TRUE);

foreach ( $file_array as $key=> $file ) {
$c_date = filectime("$files_directory/$file");
$last_mod = date("M j, h:ia", $c_date);
//echo "$file - $last_mod<BR>";

$mytext =file("files/$file"); 
foreach ($mytext as $myarray)
{ 

     $split = explode(",", $myarray); 
 
	     $date     = $split[2];
	     $status     = $split[28];
	     
	
	}   

//WRITE THE FILE LISTING
 
 echo "<tr width="600"><td width="500"><font size="2" face="Verdana">$file</font></td><td width="130" align="center"><font size="1" face="Verdana"><a href="javascript:popUp2('view.php?note=files/$file')">VIEW</a></font></td><td NOWRAP width="100" align="center"><font size="1" face="Verdana"><a href="javascript:popUp('files/$file')">SPREAD SHEET</a></font></td><td width="130" align="center"><font size="1" face="Verdana"><a href="list.php?del=files/$file" target="_self">DELETE</a> </td><td width="150" align="center">  </td><td width="150" align="center"><font size="1" face="Verdana"  color="#f93f14">$status</font></td><td align="center" width="300" class="date">$date</td></tr>";


}


closedir($fdirectory);

clearstatcache();




?>
It basicly just lists the .csv file in a dir and allows them to be viewed in a few different ways. It also displays the some of the content of the file. i.e date and status.

What I need it to do now is be able to sort the contents by date (which it is doing from newest to oldest great! :) ), status, and file name. I would like to have buttons on the top of the page to do this so I guess I would just link them to this the same page calling a fuction or something. Right?

Well I don't know how to do that so if anyone can point me in the right direction I would send you some of my mom oatmeal cookies.

TIA, :wink:

Wes/
User avatar
DuFF
Forum Contributor
Posts: 495
Joined: Tue Jun 24, 2003 7:49 pm
Location: USA

Post by DuFF »

The function sort() can probably help you. THere are also a bunch of links for other functions at the end of the example that you should look.
wesnoel
Forum Commoner
Posts: 58
Joined: Fri Sep 05, 2003 11:53 am

Post by wesnoel »

:? Well...

I should have stated that I realy have not grasped this PHP that well yet.

I was kinda hoping that someone could look at my code and give a commented code sample I could hack through.

I do have to say that everyone on this board has helped me a lot and I am learning some of it. I mean I know what an array is and I know how to loop through them now. lol :D


TIA guys,

Wes/
Post Reply