how to concatenate two fields in a list box

General discussions related to php

Moderators: macek, egami, gesf

cincihal
New php-forum User
New php-forum User
Posts: 11
Joined: Thu May 31, 2012 7:45 am

how to concatenate two fields in a list box

Postby cincihal » Fri Jul 12, 2013 5:21 am

I have a list box of last names and I would like to concatenate a ", " and first name at the end of the last name. Can someone show me how to do this? This is what I have for last name:

Code: Select all

function query() {
      $myData = mysql_query("SELECT * FROM clients ORDER BY Lname1");
      while($record = mysql_fetch_array($myData)) {
         echo '<option value="' . $record['Lname1'] . '">' . $record['Lname1'] . '</option>';
      }

johnj
php-forum Super User
php-forum Super User
Posts: 1805
Joined: Thu Mar 10, 2011 5:07 pm

Re: how to concatenate two fields in a list box

Postby johnj » Sat Jul 13, 2013 6:10 am

Code: Select all

echo '<option value="' . $record['Fname1'].",".$record['Lname1'] . '">' . $record['Lname1'] . '</option>';


Return to “PHP General”

Who is online

Users browsing this forum: Yahoo [Bot] and 1 guest