how to concatenate two fields in a list box

General discussions related to php

Moderators: macek, egami, gesf

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

how to concatenate two fields in a list box

Post by 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

Post by johnj » Sat Jul 13, 2013 6:10 am

Code: Select all

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

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests