|
Posted by Jerry Stuckle on 04/10/07 12:44
programming wrote:
> Ok well your suggestion has sort of fixed the problem but know it is
> like reading
> every 3 of 4 lines, instead of 2 of 4 lines.
>
> <?php
> $listf = fopen ("./member.txt", "r");
> # read the file
> $line = fgets($listf, 1024);
>
> while(($data = fgetcsv($listf,1024,"|"))!=FALSE)
> {
> $count++;
> $duserid=trim($data[0]);
> $dname=trim($data[1]);
>
> list ($duserid,$dname,$actions) = split("\|",$line);
> $line = chop($line); //chops space out of program
>
> $actions= "<a href=\"./delete_member.php?
> record_id=29\">Delete</a> | <a href=\"./edit_member.php?
> record_id=29\">Edit</a></td>";
> //$data = fgetcsv($listf, 1024);
> echo "<tr><td>$duserid</td><td>$dname</td><td>
> $actions<td></tr>";
>
> }
>
> fclose($listf);
> ?>
>
> may be a do while loop might fix the problem....
>
>
>
>
>
> On Apr 10, 7:13 pm, Toby A Inkster <usenet200...@tobyinkster.co.uk>
> wrote:
>> programming wrote:
>>> while(($data = fgetcsv($listf,1024,"|"))!=FALSE)
>>> {
>> [...]
>>> $data = fgetcsv($listf, 1024);
>> I'm not very familiar with fgetcsv() but you appear to be reading two
>> lines for each iteration. Which means that if the file has "n" lines,
>> you'll only end up with "n/2" iterations of the while loop.
>>
>> --
>> Toby A Inkster BSc (Hons) ARCS
>> Contact Me ~http://tobyinkster.co.uk/contact
>> Geek of ~ HTML/SQL/Perl/PHP/Python*/Apache/Linux
>>
>> * = I'm getting there!
>
>
You're also getting the first right after you open the file and throw it
away.
Did you do ANY debugging on this yourself? Do you have ANY idea what
the functions you're using do?
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
[Back to original message]
|