Target single record in MYSQL to export as CSV in a php user interface?

First use MySQL select like $query = " SELECT CONCAT('\"',ifnull(firstname,''),'\",\"',ifnull(middlename,''),'\",\"',ifnull(lastname,''),'\"') FROM relatie WHERE relatie. Id = ". $s."

AND relatie. SomeOtherThing > 1 ORDER BY relatie. Id LIMIT 1; "; $result = mysql_query($query); The ifnull's are very important because otherwise null fields in a CONCAT will make the whole CONCAT to be null, suppose middlename is null, this code will output something like: "Johan","","Smith" Without the ifnull's it will just output nothing, because the null-middlename will make the whole concat expression null.

The Order by and limit are only needed if the id is not unique, because you said you only want one line. Next put a CSV header in and output the line you saved in $result earlier. Header("Content-type: application/csv"); header("Content-Disposition: attachment; filename=file.

Csv"); header("Pragma: no-cache"); header("Expires: 0"); echo $result. "\n.

BTW put the $s in the query. – Johan Mar 10 '11 at 23:42 I've escaped the " in the php code by replacing them with \". – Johan Mar 10 '11 at 23:48.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions