Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sorting arrays

Status
Not open for further replies.

tanveer91

Programmer
Nov 13, 2001
31
GB
Hi there,

I am trying to sort the contents of an array in date order...it sort of works! ....but the problem is when i include a new file it does not display it on top of list, also it displays 2 empty rows! (the list is within a form using checkbox)...the text files are saved as the date created ie 09022002.

PLEASE HELP......here's my code:

<?php
$date = date(&quot;dmY&quot;);
$handle=opendir('results');
$array=array();
while (($array[] = readdir($handle))!==false);
arsort($array,SORT_STRING);
closedir($handle);

while(list(,$value)=each($array)){
if ($value != '.' || $value != '..') {
print (&quot;<tr><td valign=top align=left><input type=checkbox name=del[] value=${value}>
</td>&quot;);
@include(&quot;results/$value&quot;);
print (&quot;</tr>&quot;);
}
}
?>
 
change the || for &&.

It's logic.

And the fact of not displaying in the top of the list is cause you are not putting the include inside of a <td> tag.

Anikin
Hugo Alexandre Dias
Web-Programmer
anikin_jedi@hotmail.com
 
Its my friend 'Anikin' again..........your help has been greatly appreciated!!

However.........I have changed the condition from '||' to '&&' it sort of worked, except it now displays one blank line instead of two!....any ideas??

Also, the files the 'include' points to are already within <td></td> tags......so i still havn't a clue as to why it doesn't show new files at the top of list, instead it shows the new files somewhere in between!!

Look forward to your reply.
 
is it entirely blank ? is there any strange file in the dir?

the code should work fine just as you changed the || for the &&.

another thing, remove the {} in the checkbox. it's no use. Anikin
Hugo Alexandre Dias
Web-Programmer
anikin_jedi@hotmail.com
 
There is no strange file in the 'results' directory, they all are text files in the date format i.e. 10022002.

The blank line contains a checkbox followed by blank spaces!

here is the sample html output:-

<table border=0 cellpadding=3 >
<tr>
<th valign=top align=left>
<left><form method=POST name=Delete action=form_del.php>
<input type=submit name=Delete value=Delete>
</th>
<th valign=top align=left>
<b>
VERSES
</b></th>
<th valign=top align=left>
<b>
MATCH
</b></th>
<th valign=top align=left>
<b>
H/A
</b></th>
<th valign=top align=left>
<b>
S
</b></th>
<th valign=top align=left>
<b>
O
</b></th>
<th valign=top align=left>
<b>
R
</b></th>
<th valign=top align=left>
<b>
DATE
</b></th>
</tr>

<tr><td valign=top align=left><input type=checkbox name=del[] value=910092001>
</td>
<td valign=top align=left>
<font size=2 type=arial><b>
Sparton
</b></td>
<td valign=top align=left>
<font size=2 type=arial><b>
Cup
</b></td>
<td valign=top align=left>
<font size=2 type=arial><b>
Away
</b></td>
<td valign=top align=left>
<font size=2 type=arial><b>
60
</b></td>
<td valign=top align=left>
<font size=2 type=arial><b>
85
</b></td>
<td valign=top align=left>
<font size=2 type=arial><b>
L
</b></td>
<td valign=top align=left>
<font size=2 type=arial><b>
10/09/01
</b>
<input type=hidden name=matchdate value=910092001>
<input type=hidden name=delfile[] value=910092001>
</td>
</tr><tr><td valign=top align=left><input type=checkbox name=del[] value=904082001>
</td>
<td valign=top align=left>
<font size=2 type=arial><b>
Howten
</b></td>
<td valign=top align=left>
<font size=2 type=arial><b>
League
</b></td>
<td valign=top align=left>
<font size=2 type=arial><b>
Home
</b></td>
<td valign=top align=left>
<font size=2 type=arial><b>
85
</b></td>
<td valign=top align=left>
<font size=2 type=arial><b>
25
</b></td>
<td valign=top align=left>
<font size=2 type=arial><b>
W
</b></td>
<td valign=top align=left>
<font size=2 type=arial><b>
04/08/01
</b>
<input type=hidden name=matchdate value=904082001>
<input type=hidden name=delfile[] value=904082001>
</td>
</tr><tr><td valign=top align=left><input type=checkbox name=del[] value=>
</td>
 
well i saw the file and only a thing.

i presume i know what's bugging you.

it's an IE bug. Put the form tag inside the <th> and the </form> before the last <tr>

This can be your problem.

Another thing, strip all that font tags that are not being closed.

Anikin
Hugo Alexandre Dias
Web-Programmer
anikin_jedi@hotmail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top