ztealmax Posted December 12, 2006 Share Posted December 12, 2006 Hi need a bit of help, i have this code that lists all files in a folder sorted by date![code]<?php $this = $PHP_SELF; $dir = $DOCUMENT_ROOT."x101_news/"; $files = opendir($dir); $file_list = array(); $file_sort = array(); if(empty($sort))$sort="name"; if(empty($r)) $r=0; $cnt = 1; while ($file = readdir($files)) { $full_path = $dir."/".$file; if(!is_dir($full_path)) { $ext = explode(".",$file); $i=count($ext); if($i>1)$file_details["ext"] = strtolower($ext[$i-1]); $file_details["name"] = $ext[0]; $file_details["date"] = filectime($full_path); $file_list[$cnt] = $file_details; $key = strtolower($file_details[$sort]); $file_sort[$cnt] = $key; $cnt++; } } if($r)arsort($file_sort); else asort($file_sort); ?><link href="../webmax.css" rel="stylesheet" type="text/css"><table width="465" border="0" cellpadding="3" cellspacing="0" class="bodytext"> <tr> <td width="174"><a href="<?php print($this);?>?sort=name&r=<?php print(!$r);?>">Name</a></td> <td width="141"><a href="<?php print($this);?>?sort=date&r=<?php print(!$r);?>">Date</a></td> </tr> <tr bgcolor="#0033CC"> <td height="3" colspan="5"> </td> </tr><?php while(list($key, $value)=each($file_sort)){ $value = $file_list[$key];?> <tr> <td width="174"><?php print($value["name"]);?></td> <td width="141"><?php print(date("Y/m/d H:i",$value["date"]));?></td> </tr><?php}?></table>[/code]however i would like to make the files clickable so i can read them with read text file thingyThat is a want to make the list clickable so it opens the document i click on!tthis is my read text file thingy, but it has the document name already in the code [code]<?php$filename = 'news/*.*';// set file to read$file = 'news/textdoc.txt';// open file $fh = fopen($file, 'r') /*or die('Could not open file!')*/;// read file contents$data = fread($fh, filesize($file)) /*or die('Could not read file!')*/;// close file fclose($fh); // print file contents echo $data; ?>[/code]anyone know a way to do this?//Martin Quote Link to comment Share on other sites More sharing options...
ztealmax Posted December 13, 2006 Author Share Posted December 13, 2006 Okej guys and girls, somebody knows how to make the data to link? Quote Link to comment Share on other sites More sharing options...
trq Posted December 13, 2006 Share Posted December 13, 2006 [code]<td width="174"><a href="<?php print($value["name"]);?>"><?php print($value["name"]);?></a></td>[/code] Quote Link to comment Share on other sites More sharing options...
ztealmax Posted December 13, 2006 Author Share Posted December 13, 2006 [quote author=thorpe link=topic=118279.msg483827#msg483827 date=1165982691][code]<td width="174"><a href="<?php print($value["name"]);?>"><?php print($value["name"]);?></a></td>[/code][/quote]Thanx got it working :D :D Quote Link to comment Share on other sites More sharing options...
trq Posted December 13, 2006 Share Posted December 13, 2006 What doesn nto working meen? Quote Link to comment Share on other sites More sharing options...
ztealmax Posted December 13, 2006 Author Share Posted December 13, 2006 Got it working, i well placed the code in the wrong place ;) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.