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 Link to comment https://forums.phpfreaks.com/topic/30325-resolved-make-as-a-clickable-link/ 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? Link to comment https://forums.phpfreaks.com/topic/30325-resolved-make-as-a-clickable-link/#findComment-140140 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] Link to comment https://forums.phpfreaks.com/topic/30325-resolved-make-as-a-clickable-link/#findComment-140160 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 Link to comment https://forums.phpfreaks.com/topic/30325-resolved-make-as-a-clickable-link/#findComment-140169 Share on other sites More sharing options...
trq Posted December 13, 2006 Share Posted December 13, 2006 What doesn nto working meen? Link to comment https://forums.phpfreaks.com/topic/30325-resolved-make-as-a-clickable-link/#findComment-140174 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 ;) Link to comment https://forums.phpfreaks.com/topic/30325-resolved-make-as-a-clickable-link/#findComment-140177 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.