June 17, 2013
Assign multiple DB field entries to a single variable
User1615837’s Question:
I have a PHP question, which I was hoping someone might be able to answer quite easily…
Basically the code exports database fields into an excel file, but I need two database fields to be added to a single excel field:
Normal working single db field:
$worksheet->writeString( $i, $j++, $row['date_added'] );
Not working (in this case I would like both ‘shipping_firstname’ and ‘shipping_lastname’ to be added to a single excel cell):
$worksheet->writeString( $i, $j++, $row['shipping_firstname'] && $row['shipping_lastname'] );
Any help would be greatly appreciated!
Concatenations are using a dot(.
) on PHP
$worksheet->writeString( $i, $j++, $row['shipping_firstname'] . " " . $row['shipping_lastname'] );
&&
is used to combined boolean value and is mostly used in conditional statement like if