Hello all,

a few things csv related;

first how can I page fGetCsv ?

lets say I want to return somestring in chuncks of 20 then display page 1, 2,3 etc links


$rows = 0;
while ($data = fGetCsv ($csv_fp, 10000, ",")) 
					{

 if($rows == 0){
 // DO NOTHING THIS IS COL HEADER ROW |||


 }else{

$somestring = $somestring ."".$data[6]."','".$data[9]."','".$data[7]."','".$data[11]."','".$data[10]."','0','".trim($data[3])."','".$_GET['mer']."'";


 }


 $rows++;
}

Next how can I filter based on price high and low, row 0 is the column headers of the csv file

with asp I can simply connect to and use a sql statment as I would a database can we not do this with PHP?

Thanks all in advance 🙂

    skip wrote:

    with asp I can simply connect to and use a sql statment as I would a database can we not do this with PHP?

    Are you referring to [man]ODBC[/man]?

    But for pagination the word you'll want to search for is "pagination" (or look at this forum's FAQ).

      Hi thanks for the reply paging db results is not a problem the problem is paging the results of fgetcsv I know the number of rows in the csv file I know how many rows per page I want. I don't know where how to set the start and end points for the loop I wouldn't want to loop the entire file just to pull the last 20 rows

        You'll need to, because you can't tell where the rows start and end without finding the linebreaks between them. And you can't find those without reading the file.

          Knickers 🙂 Will have to go with plan B thanks for your help m8 😃

            Write a Reply...