[thelist] PHP writing to a csv file

Andrew Maynes andrew at uk-webdeveloper.co.uk
Mon Apr 8 11:35:01 CDT 2002


I did produce a tab
delimiting file and the code is already there

here is a bit of the code

//* write the products (or a product) into a buffer, that will be shown later.
*/

		if ($s[0] == "END" && $temp[GROUP] && $temp[NAME] && $temp[UNIT_PRICE] && ($g
== $temp[MD5GROUP] || $p == $temp[MD5NAME])) {

			$number_of_products++;

			if ($p && $p != $temp[MD5NAME]) continue;

			if (!$p && ($number_of_products < $min || $number_of_products > $max))
continue;

			if ($p && !$g) $buffer_topic .= "$temp[NAME]";

			if (!$p && $g && !$product_found) $buffer_topic .= "$temp[GROUP]";

-----Original Message-----
From: thelist-admin at lists.evolt.org
[mailto:thelist-admin at lists.evolt.org]On Behalf Of Martin Kuplens-Ewart
Sent: Monday, April 08, 2002 05:04
To: thelist at lists.evolt.org
Subject: RE: [thelist] PHP writing to a csv file


> I am having problems writing to a csv file does anyone know of a good
tutorial

I just did it by doing it...
...erm, what kind of problem are you having?

If it's an issue with data spilling over into different columns
[probably caused by commata in the data itself], may I suggest using tab
delimiting?

Gets really easy with that.
Eg:

FieldName1	FieldName2	FieldName3
<?
$q = "SELECT * FROM $db.$table";
$qe = mysql_query($q);
while($qr = mysql_fetch_array($qe))
{
?>
<?=$qr[Field1]?>	<?=$qr[Field2]?>	<?=$qr[Field3]?>

<?
}
?>

Replace the field name stuff with the names of fields [if you want a key
included], and the query result field names too...

-m


--
For unsubscribe and other options, including
the Tip Harvester and archive of thelist go to:
http://lists.evolt.org Workers of the Web, evolt !
---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.343 / Virus Database: 190 - Release Date: 3/22/02

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.343 / Virus Database: 190 - Release Date: 3/22/02





More information about the thelist mailing list