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

Author: Nabin Nepal (Starx)

Hello, I am Nabin Nepal and you can call me Starx. This is my blog where write about my life and my involvements. I am a Software Developer, A Cyclist and a Realist. I hope you will find my blog interesting. Follow me on Google+

...

Please fill the form - I will response as fast as I can!