Board index   FAQ   Search  
Register  Login
Board index PHP PHP General

how to concatenate two fields in a list box

General discussions related to php

Moderators: macek, egami, gesf

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>';
      }
cincihal
New php-forum User
New php-forum User
 
Posts: 11
Joined: Thu May 31, 2012 7:45 am

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>';
johnj
php-forum Super User
php-forum Super User
 
Posts: 1805
Joined: Thu Mar 10, 2011 5:07 pm


Return to PHP General

Who is online

Users browsing this forum: No registered users and 3 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.