Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP][HTML]jak połączyc dwie funkcje ?, - na przykładzie
Luki2604
post
Post #1





Grupa: Zarejestrowani
Postów: 16
Pomógł: 0
Dołączył: 17.01.2007

Ostrzeżenie: (0%)
-----


hej, uzywam dwóch funkcji w różnych skryptach:

$html .= "$val - <a href=\"?deleteFile=$val\">Usun</a><hr><br>";

oraz

$html .= $val .' Odnotowano: '. date('H:i:s. d-F-Y.', filemtime($aDir."/".$val))."</a><hr><br>";

jak połączyc te dwie funkcje, aby były w jednym wierszu? ... próbowałem tak:

$html .= $val .' Odnotowano: '. date('H:i:s. d-F-Y.', filemtime($aDir."/".$val))." - <a href=\"?deleteFile=$val\">Usun</a><hr><br>";

wtedy link USUN działa i usuwa plik, ale zarazem wywala błąd:

Warning: filemtime(): Stat failed for ./myfiles/CKK- 12597 (errno=2 - No such file or directory) in c:\usr\krasnal\www\tele\filestv.php on line 66
Usunieto ./myfiles/CKK- 12597
CKK- 12597 Odnotowano: 01:00:00. 01-January-1970. - Usun

Proszę o pomoc, bo już nie wiem, w czym błąd :/

Dzięki i pozdrawiam !
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
Luki2604
post
Post #2





Grupa: Zarejestrowani
Postów: 16
Pomógł: 0
Dołączył: 17.01.2007

Ostrzeżenie: (0%)
-----


u mnie to tak wygląda:

  1. <?php
  2. function dirList ($directory)
  3. {
  4.    $results = array();
  5.    $handler = opendir($directory);
  6.    while ($file = readdir($handler)) {
  7.  
  8.        if ($file != '.' && $file != '..' && is_file($directory."/".$file) == TRUE)
  9.            $results[] = $file;
  10.    }
  11.  
  12.    closedir($handler);
  13.    return $results;
  14. }
  15.  
  16. header('Content-type: text/html; charset=utf-8');
  17.  
  18. //<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  19. $html = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">';
  20. $html .= '<html>';
  21. $html .= '<head>';
  22. $html .= '<meta http-equiv="refresh" content="4;url=http://crm2.orcansi.com/luki/files.php" />';
  23. $html .= '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">';
  24. $html .= '<title>';
  25. $html .= "Pliki";
  26. $html .= '</title>';
  27. $html .= '</head>';
  28. $html .= '<body>';
  29. $html .= "<div>";
  30.  
  31. $aDir = "./myfiles";
  32.  
  33. $files = dirList($aDir);
  34.  
  35. if (TRUE == array_key_exists("deleteFile", $_GET))
  36.  {
  37.  $file = $aDir."/".$_GET["deleteFile"];
  38.  if ($file == $_SERVER["SCRIPT_NAME"])
  39.    {
  40.    $html .= "Nie mozna usunac <br>";
  41.    }
  42.    else if (file_exists($file) && unlink($file))
  43.    {
  44.    $html .= "Usunieto $file<hr><br>";
  45.    }
  46.  else
  47.    {
  48.    $html .= "Blad podczas usuwania $file<br>";
  49.    }
  50.  }
  51. foreach ($files as $val)
  52.  {
  53.  $html .= "$val - <a href=\"?deleteFile=$val\">Usun</a><hr><br>";
  54.  }
  55.  
  56. $html .= "</div>";
  57. $html .= '</body>';
  58. $html .= '</html>';
  59.  
  60. echo $html;
  61. ?>


ok, już znalazlem błąd (IMG:http://forum.php.pl/style_emoticons/default/smile.gif)
trzeba wiersz
  1. <?php
  2. $files = dirList($aDir);
  3. ?>
przenisc nizej przed
  1. <?php
  2. foreach ($files as $val)
  3. ?>
i jest ok.

A wiecie może jak zrobić, aby wyświetlało posortowane np wg daty ? Teraz wyświetla wg nazwy

Ten post edytował Luki2604 29.07.2009, 15:40:48
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 27.12.2025 - 06:23