mohson wrote:Ive had a look over my downloading data code and ive finally got it to work im experiencing one problem though all the data is currently being printed on screen - I was told by a technical expert that I need to change the header code to one which opens a file save box rather than print the raw data on screen - can someone help with regards to the correct header information.
the working code is below:
Code: Select all
<?php header ("Content-type: text/csv"); /* Connecting, selecting database */ $link = mysql_connect("xxxx", "xxx", "xxxx") or die("Could not connect : " . mysql_error()); mysql_select_db("contact_management_system",$link) or die("Could not select database"); //This is my code, change your queries and formatting $query = "SELECT * FROM people ORDER BY organisation"; $result = mysql_query($query) or die(mysql_error()); while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) printf ("%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s\n", $line['person_id'],$line['salutation'],$line['firstname'], $line['surname'],$line['organisation'],$line['role'], $line['address1'],$line['address2'],$line['city'],$line['postcode'], $line['telephone'],$line['mobile'],$line['fax'], $line['dateoflastcontact'],$line['datecontactagain'], $line['notes'],$line['email'],$line['org_id'] ); ?>
Can anyone help with this
Moderator: General Moderators
Can anyone help with this
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
look at the header() documentation, we've also talk a lot about forcing a download. 
http://php.net/function.header
http://php.net/function.header