1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Rep Power

    Multiple column data in echo statement

    Since my last few posts I have gained a better understanding of PHP and feel more comfortable with the code.

    How do I pull data from multiple columns into one <td> echo statement?

    PHP Code:
    <td>Name:</td><?php echo $customer['first_name' AND 'last_name']; ?>

    That is what I've tried, it returns only the firstName. I have tried to concatenate it but I'm stumped. Any help is appreciated.

    Also, I don't know if it matters but I have a
    PHP Code:
    foreach (customers as customer) : ?> 
  2. #2
  3. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Pennsylvania, USA
    Rep Power

    PHP Code:
    <td>Name:</td><?php echo $customer['first_name'] . ' ' $customer['last_name']; ?>

    PHP Code:
    <td>Name:</td><?php echo $customer['first_name']; ?> <?php echo $customer['last_name']; ?>
    The former is more correct
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.

IMN logo majestic logo threadwatch logo seochat tools logo