Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [PHP][HTML][CSS]Czyatnie z pliku do tabeli, Pusty row tabeli
HgReed
post 19.11.2011, 11:56:26
Post #1





Grupa: Zarejestrowani
Postów: 59
Pomógł: 0
Dołączył: 13.11.2011

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


Witam.
Gdy czytam z pliku listę plików a potem ją wyświetlam w tabeli, zawsze jest jeden "row" za dużo. Niezrozumiale? To przykład : załóżmy że w pliku z listą mam 5 plików. PHP wyciąga to i ładnie wyświetla, ale wyświetla 6 "row'ów" w tabeli. Nie jest to estetyczne (dodatkowe 10px pod tabelą).

Skrypt wyciągania listy plików :

  1. <table id="linkTable">
  2. <tbody>
  3. <tr>
  4. <th align="center" width="20%">Nazwa pliku</th>
  5. <th align="center" width="15%">Dodano</th>
  6. <th align="center">Opis pliku</th>
  7. </tr>
  8. <?php
  9. $logFile = file_get_contents("upload/filesLog.txt");
  10. $testingRaw = explode("\n", $logFile);
  11. foreach($testingRaw as $testingHalfCooked)
  12. {
  13. $testingFullCooked = explode('||', $testingHalfCooked);
  14. echo '<tr><td align="center"><a href="/'.$testingFullCooked[1].$testingFullCooked[0].'" target="_blank">'.$testingFullCooked[0]. '</a></td><td>'.$testingFullCooked[2].'</td><td>'.$testingFullCooked[3].'</td></tr>';
  15. }
  16. unset($testingRaw, $testingHalfCooked, $testingFullCooked);
  17.  
  18. ?>
  19. </tbody>
  20. </table>


A to CSS do tabel (nie ma kolorowania CSS, więc w html):

  1. #linkTable {
  2. background-color: #FFF;
  3. border: 1px solid #BBB;
  4. border-collapse: collapse;
  5. width: 100%;}
  6. #linkTable th {
  7. padding: 3px;
  8. background-color: #EEE;
  9. border: 1px solid #BBB;
  10. vertical-align: top;}
  11. #linkTable td {
  12. padding: 3px;
  13. border: 1px solid #BBB;
  14. vertical-align: top;}


Czy coś robię źle? Jeżeli tak, to co?

Pozdro

//EDIT: CuteOne - działa smile.gif Do zamknięcia

Ten post edytował HgReed 19.11.2011, 13:02:05
Go to the top of the page
+Quote Post
CuteOne
post 19.11.2011, 12:51:44
Post #2





Grupa: Zarejestrowani
Postów: 2 958
Pomógł: 574
Dołączył: 23.09.2008
Skąd: wiesz, że tu jestem?

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


  1. <?php
  2. $logFile = file("upload/filesLog.txt");
  3.  
  4. foreach($logFile as $v)
  5. {
  6.  
  7. if(!empty($v)) {
  8.  
  9. $testingFullCooked = explode('||', $v);
  10.  
  11. echo '<tr><td align="center"><a href="/'.$testingFullCooked[1].$testingFullCooked[0].'" target="_blank"> '.$testingFullCooked[0]. '</a></td><td>'.$testingFullCooked[2].'</td><td>'.$testingFullCooked[3].'</td></tr>';
  12. }
  13. }
  14.  
  15.  
  16. ?>


Ten post edytował CuteOne 19.11.2011, 12:51:56
Go to the top of the page
+Quote Post

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

 



RSS Wersja Lo-Fi Aktualny czas: 12.06.2025 - 13:31