[thelist] combining multiple fields in db
Liam Delahunty
ldelahunty at britstream.com
Thu Dec 5 08:05:01 CST 2002
Les Lytollis wrote:
>I need to produce a comma delimited text file in the format Artist,
>Description, Price. My existing db is in the format Artist, Title, Format,
>Grade, Comments, Cat No., Price.
You could have a problem with the text fields, if commas are in there then
they could cause the data to mess about. You may want to replace them with
another character...
$query = "SELECT * FROM table_name WHERE ...WHATEVER...";
if ($result = mysql_query($query,$connection)){
while ($myrow = mysql_fetch_row($result)) {
$artist = stripslashes($myrow[0]);
$title = stripslashes($myrow[1);
$format = stripslashes($myrow[2);
$grade = stripslashes($myrow[3);
$comments = stripslashes($myrow[4);
$cat_no = stripslashes($myrow[5);
$price = stripslashes($myrow[6);
$csv_array[] = "$artist, $title $format $grade $comments $cat_no, $price";
}
}
then do whatever you want to do with the csv_array. Such as sort it and
output the file.
Kind regards,
Liam Delahunty
Mega Products Limited, 10-11 Moor Street, Soho, London W1D 5NF
t: 020 7434 4201 f: 0870 135 8412
http://www.liamdelahunty.com/ web/ design/ database/ programming
http://www.britstream.com/ Hosting/ Domain Names From UKP 7.50 p.a.
More information about the thelist
mailing list