I have a PHP script that is exporting a mysql query to a | delimited file. This working great except for the last "column" is appending a | pipe when I don't need it to.
$values = mysql_query("SELECT ColumnA AS Name, ColumnB AS Address, ColumnC AS Phone FROM Table1");
$row = 0;
while ($rowr = mysql_fetch_assoc($values))
{
if ($row == 0)
$row++;
$csv_output .= "id|";
foreach($rowr as $name => $value)
{
$csv_output .= $value."|";
}
$csv_output .= "\n";
}
The end result looks like
Name|Address|Phone|
Name|Address|Phone|
Name|Address|Phone|
How do I avoid having the ending pipe after the Phone| so it looks like this:
Name|Address|Phone
Name|Address|Phone
Name|Address|Phone