I’m trying to combine several results from an array into one variable.
$sqlNameForCode = "Select dim_InvoiceRef from dimensions"." Where dim_FileRef = '".$addRow[$FieldName]."'";
$qryNameForCode = mysql_Query($sqlNameForCode);
While($arrNameForCode = mysql_fetch_array($qryNameForCode)) {
$addRow[$FieldName] = $arrNameForCode['dim_InvoiceRef'];
}
I need the variable $addRow[$FieldName] to contain all the fields taken from the array. However because it’s within the While loop only the last field is ever left in the variable.
Example, the query pulls the following results
Apple
Banana
Orange
I need echo $addRow[$FieldName] to show Apple Banana Orange, at the moment it just equals Orange.
Any help would be great thanks!
Here’s a MySQL-based solution that you might find easier:
I took the liberty of renaming some variables in your example to make it easier to understand. Unless you need to do different things with the same data later on in the program, this should work.