0

hallo there everyone..
i got an array from my database

$save=split("[|;]",$listOfItems);

and what i want i s after making some changes to the attributes on the array above to export them on an csv or excel format
but directly as a message to the browser ..
i dont want it to be saved on the server ...
what i cant understand from the examples i found on the net and some on this particular forum ..
is how to handle the files and which are created cause
i just have the array in a php file nothing more...


another thing i have in mind is to export from the ldap server the files directly but seems to me as the wrong way to do it

thanks

2
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by colweb
0

PHP runs on the server. So you can create a file on the server and write your data to it. If you have a database and do a query with a PHP script, all that data is still on the server and will only go to the client is you use it to create a webpage.

I don't know what kind of data you want to export to excel, but maybe you could do it with an stored procedure in your mySQL database. With the mySQL query browser you can export to a csv file or excel file without a problem.

If you have to stick to a PHP script, create a csv file on the server and download it to your windows machine.

0

i just wondered if there is a way of handling the data i get from a search in my ldap tree(database) and use them in a way to fill asimple excel table
with the name last name and stuff as labels..

i dont wanto to use a mysql server and dont thing the query i have indeed found will work for my data that are saved as an array in the save variable !..

i think is not that difficult but i am really confused with what i found on the net

thank you for your answer

-1

Creating a file and writing to it is not so difficult. You could use something like this code:

<?php 
$file = "YourFile.csv"; 
$handle = fopen($File, 'w');
for ($i = 0; $i < count($array); ++$i) {
        $date = $array[$i].",";
        fwrite($handle, $data); 
}
 fclose($Handle); 
 ?>

You have to modify the line where $data is filled with the contents or your array.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.