Forum Moderators: coopster
I've written a php code for parsing a CSV file.
I have also managed to pass the arrays with the CSV data stored into a tabular format for displaying on a webpage.
Now, my question, is it possible to output this tabular formatted data to a new webpage. So when the data is generated, I would like it to be displayed on a new webpage instead of being displayed on the same page from where the script was executed.
Thank you in advance
vivek
Can you give me an example of its usuage ? I'm unable to understand how using this statement and at what position would get my tabulated data over to a new page.
Also, I think I should have explained this properly. I'm generating arrays and storing data from the CSV files. And using 'for' loops I fill in the data in the HTML table I create within php by using commands such as
....<snip>....echo '<table>';
echo '<tr>';
for ($x=0; $x < $number_of_fields; $x++)
{
echo '<td align="Left" nowrap="nowrap">'.$data[$x].'</td>';
}
echo '</tr>';
echo '</table>';
....<snip>....
Thanks
Vivek
What I also did was added a button to my script which when clicked will open a popup window with the 'example.html' file loaded on it.
the popup code i used
<input type="submit" value="See my CSV Data " onClick="javascript: window.open('example.html', 'CSV Table', 'toolbar=1, scrollbars=1, location=0, statusbar=1, menubar=1, resizable=1,width = 600, height = 400');">
Just one last question, is there a way which I'm sure there is, for php to create the 'example.html' automatically on the fly if at all a flag such as "record the parsed csv data" is checked.
This way I won't need to manually create a 'example.html' file so that php can open it up and then write on it. Also, then in my popup code
window.open('example.html'.....
the above filename could be replaced by the one php creates on the fly.
Therefore, if example.html already exists and if the record flag is checked, the php script can create example_001.html and write the data on it and then pass this filename to the popup script so that if the user clicks the button, then only the recently newly created 'example_001.html' file is opened.
Thanks
Vivek
<?
if($_POST['record']){
$out ='<html><body><table><tr>';
for ($x=0; $x < $number_of_fields; $x++)
{
$out.='<td align="Left" nowrap="nowrap">'.$data[$x].'</td>';
}
$out.='</tr></table></body></html>';
$filename="example";
$file_EXT=".html";
$count=0;
while(file_exists($filename.($count>0?"_".$count:"").$file_EXT)){
$count++;
}
$filename=$filename.($count>0?"_".$count:"").$file_EXT;
$fh = fopen($filename, "w");
fwrite($fh,$out);
fclose($fh);
header("Location: ".$filename);
}
?>