View Single Post
  #19  
Old 12-08-2010, 06:48 PM
atholon is offline atholon
"ath-hole"

Join Date: Jan 2003
Location: Failville.
Posts: 11,357

Send a message via MSN to atholon
Bam, atholon fail, you'd use the function explode();

Here you go:
Code:
<?php

$file = fopen("yourfile.csv", "r") or exit("Unable to open file!");

// Row array
$rows = array();

while(!feof($file))
{
  $columnString = fgets($file);
  $columns = explode(",", $columnString);

  // Add the array of column items to the row
  $rows[] = $columns;  
}
// This would return ALL the data to the javascript with AJAX
echo(json_encode($rows));
?>
You could get away with making multiple AJAX requests and having the code behind filter it but I suggest just doing one AJAX request at the time the page loads. That way you don't have the annoying delay while the results are passed back.
__________________

Last edited by atholon; 12-08-2010 at 07:06 PM.
Reply With Quote