R: [PHP-WIN] Newbie Question
| From: | Alberto. Sartori | Date: | Mon, 08 Apr 2002 13:31:14 +0000 |
| Subject: | R: [PHP-WIN] Newbie Question | ||
| Groups: | php.windows | ||
| Request: | Send a blank email to php-windows+get-12964@lists.php.net to get a copy of this message | ||
You should do the cicle and get the datas until you reach the end of file aka feof($fp) or better,
try to use fread()
-----Messaggio originale-----
Da: Mike Flynn [mailto:mike@mikeflynn.net]
Inviato: lunedì 8 aprile 2002 15.30
A: Hubert DAUL; php-windows@lists.php.net
Oggetto: Re: [PHP-WIN] Newbie Question
Give this a shot...
<?php
$row = 1;
$fp = fopen ("album.dat","r");
while ($data = fgets($fp)) {
$values = explode(';', $data);
list($vignette, $photo, $marque, $nom, $pdfproduit, $commprod) = $values;
print("<tr>");
print("<td>$vignette</td>");
print("<td><img src=\"images/$photo\"><a
href=\"prod.php?file=lecteur.dat\"></a></td>");
print("<td>$marque</td>");
print("<td>$nom</td>");
print("<td>$pdfproduit</td>");
print("<td>$commprod</td>");
print("</tr>");
}
?>
At 08:54 AM 4/8/2002 +0200, Hubert DAUL wrote:
>Hi ,
>
>Here's my problem :
>
>I read a data file (no sql file) which contains 8 lines, and in each line, 8
>datas
>
>(ex: name1;picture1;title1;anything1;everything1;nothing1)
>
>and when i run it I see only one picture(the second data) and not all of
>them
>
>If someone could help me
>
>TYA
>
>Here the code :
>
><?php $row = 1; $fp = fopen ("album.dat","r"); while ($data = fgetcsv
>($fp, 1000, ";")) { $num = count ($data); $row++; if (isset($vignette)) {
>print("
>"); print("$vignette"); // I think it's wrong here but I dont know why
>==>
>print("10e834.jpg"); print("$marque"); print("$nom");
>print("$pdfproduit"); print("$commprod"); print("
>"); } for ($c=0; $c<$num; $c++) switch ($c) { case 0 : { $vignette =
>$data[$c]; break; } case 1 : { $photo= $data[$c]; break; } case 2 : {
>$marque= $data[$c]; break; } case 3 : { $nom = $data[$c]; break; } case 4
>: { $pdfproduit= $data[$c]; break; } case 5 : { $commprod = $data[$c];
>break; } } } ?>
>
>
>
>
>--
>PHP Windows Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php
Mike Flynn - Burlington, VT
http://www.mikeflynn.net/ - mike@mikeflynn.net
home=>work=>home=>store=>home [repeat daily]