Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [php] tablica, jak ją includować
-Guest-
post 7.05.2006, 12:29:12
Post #1





Goście







w pliku dane.dat mam przykładowo:
Kod
<img src="1.gif"> | &nbsp;&raquo;&nbsp; | Strona1 | Opis1 | <img src="2.gif">
<img src="1.gif"> | &nbsp;&raquo;&nbsp; | Strona2 | Opis2 | <img src="2.gif">
<img src="1.gif"> | &nbsp;&raquo;&nbsp; | Strona3 | Opis3 | <img src="2.gif">
<img src="1.gif"> | &nbsp;&raquo;&nbsp; | Strona4 | Opis4 | <img src="2.gif">
<img src="1.gif"> | &nbsp;&raquo;&nbsp; | Strona5 | Opis5 | <img src="2.gif">
<img src="1.gif"> | &nbsp;&raquo;&nbsp; | Strona6 | Opis6 | <img src="2.gif">
<img src="1.gif"> | &nbsp;&raquo;&nbsp; | Strona7 | Opis7 | <img src="2.gif">
<img src="1.gif"> | &nbsp;&raquo;&nbsp; | Strona8 | Opis8 | <img src="2.gif">
<img src="1.gif"> | &nbsp;&raquo;&nbsp; | Strona9 | Opis9 | <img src="2.gif">

jak to includować do linki.php aby z tego otrzymac np:
Kod
<img src="1.gif">&nbsp;&raquo;&nbsp;<a href="http://www.mp.pl/" target="_blank">Medycyna Praktyczna</a>
<img src="1.gif">&nbsp;&raquo;&nbsp;<a href="http://www.mp.pl/" target="_blank">Medycyna Praktyczna</a>
<img src="1.gif">&nbsp;&raquo;&nbsp;<a href="http://www.mp.pl/" target="_blank">Medycyna Praktyczna</a>
<img src="1.gif">&nbsp;&raquo;&nbsp;<a href="http://www.mp.pl/" target="_blank">Medycyna Praktyczna</a>
<img src="1.gif">&nbsp;&raquo;&nbsp;<a href="http://www.mp.pl/" target="_blank">Medycyna Praktyczna</a>
<img src="1.gif">&nbsp;&raquo;&nbsp;<a href="http://www.mp.pl/" target="_blank">Medycyna Praktyczna</a>
<img src="1.gif">&nbsp;&raquo;&nbsp;<a href="http://www.mp.pl/" target="_blank">Medycyna Praktyczna</a>
<img src="1.gif">&nbsp;&raquo;&nbsp;<a href="http://www.mp.pl/" target="_blank">Medycyna Praktyczna</a>
<img src="1.gif">&nbsp;&raquo;&nbsp;<a href="http://www.mp.pl/" target="_blank">Medycyna Praktyczna</a>
Go to the top of the page
+Quote Post
Master Miko
post 7.05.2006, 12:38:18
Post #2





Grupa: Zarejestrowani
Postów: 530
Pomógł: 0
Dołączył: 15.01.2005
Skąd: Warszawa

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


1. Używasz systemu plików aby wczytać plik: fopen" title="Zobacz w manualu php" target="_manual a potem użyć function.fgets.php" title="Zobacz w manualu php" target="_manual
2. W pętli używasz funkcji explode, aby stworzyć tablicę na postawie oddzielacza " | " poczytaj: http://forum.php.pl/index.php?showtopic=45876&hl=explode

Proste... tylko w pliku dane.dat polecam Ci pozbyć się spacji pomiędzy danymi a | lub użyć spacera " | ".

Było wielokrotnie na forum leniu smile.gif

Ten post edytował Master Miko 7.05.2006, 12:40:20


--------------------
Go to the top of the page
+Quote Post
-Guest-
post 7.05.2006, 12:48:49
Post #3





Goście







wiem ze jestem leń smile.gif
ale wymyslilem cos takiego
  1. <?php
  2.  
  3. $file="linki.dat";
  4. $fd = fopen ("$file", "r");
  5. $dane = fread ($fd, filesize ("$file"));
  6. $tmp=explode("|",$dane);
  7. echo "$tmp[0]$tmp[1]$tmp[2]$tmp[3]$tmp[4]<br />";
  8.  
  9. ?>

a odpoweidnie $tmp w pliku linki.dat to
Kod
<img src="1.gif"> | &nbsp;&raquo;&nbsp; | Strona | Opis | <img src="2.gif">
Go to the top of the page
+Quote Post
-Guest-
post 7.05.2006, 13:11:00
Post #4





Goście







zrobilem tak:
linki.php:
  1. <?php
  2.  
  3. $file="linki.dat";
  4. $fd = fopen ("$file", "r");
  5. $dane = fread ($fd, filesize ("$file"));
  6. $tmp=explode("|",$dane);
  7. echo "<img src=\"images/cross.gif\" alt=\"\" width=\"15\" height=\"16\" border=\"0\" align=\"middle\" />&nbsp;&raquo;&nbsp;<a href=\"$tmp[0]\" target=\"_blank\">$tmp[1]</a> - <img border=\"0\" align=\"middle\" src=\"http://pr.blogflux.com/pr3.php?s=$tmp[0]\"<br />";
  8.  
  9. ?>

linki.dat:
Kod
http://www.mp.pl/ | Medycyna Praktyczna
http://www.mp.pl/ | Medycyna Praktyczna
http://www.mp.pl/ | Medycyna Praktyczna
http://www.mp.pl/ | Medycyna Praktyczna
http://www.mp.pl/ | Medycyna Praktyczna
http://www.mp.pl/ | Medycyna Praktyczna
http://www.mp.pl/ | Medycyna Praktyczna
http://www.mp.pl/ | Medycyna Praktyczna
http://www.mp.pl/ | Medycyna Praktyczna
http://www.mp.pl/ | Medycyna Praktyczna
http://www.mp.pl/ | Medycyna Praktyczna
http://www.mp.pl/ | Medycyna Praktyczna
http://www.mp.pl/ | Medycyna Praktyczna
http://www.mp.pl/ | Medycyna Praktyczna

i wyswietla mi tylko pierwsza pozycje sad.gif
Go to the top of the page
+Quote Post
matrach
post 7.05.2006, 13:35:23
Post #5





Grupa: Zarejestrowani
Postów: 92
Pomógł: 0
Dołączył: 17.04.2006

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


Zamiast fread najlepiej użyć funkcji file()
  1. <?php
  2.  
  3. $file="plik.txt";
  4. $dane = file($file);
  5.  
  6. foreach ($dane as $dana)
  7. {
  8. $tmp=explode("|",$dana);
  9.  echo '<img src="images/cross.gif" alt="" width="15" height="16" border="0" align="middle" />&nbsp;&raquo;&nbsp;<a href="' . $tmp[0] . '" target="_blank">'.$tmp[1].'</a> - <img border="0" align="middle" src="http://pr.blogflux.com/pr3.php?s='.$tmp[0].'"<br />';
  10. }
  11. ?>

I usuń odstęp w pliku linki.dat pomiędzy "|", a danymi
Go to the top of the page
+Quote Post
-Guest-
post 7.05.2006, 14:11:43
Post #6





Goście







dzięki, a efekt można obejrzeć na tej stronie
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: 18.07.2025 - 05:52