wantabe2
asked on
PHP Code Question (Displaying of Data)
Hello,
The following code displays some data from a MySQL database in a form on a web browser.
fname represents the first name of a person & lname is the last name. CUrrently I have a column names "First Name" & one named "Last Name". My question is, if I create a column named "Client Name" & want to place the full name in it, how do I do that? Or in other words, how would I edit my code so it would show John Doe in the field as opposed to John in one field & Doe in another? Thanks
The following code displays some data from a MySQL database in a form on a web browser.
<td><?php echo "".$row['fname']; ?></td>
<td><?php echo "".$row['lname']; ?></td>
fname represents the first name of a person & lname is the last name. CUrrently I have a column names "First Name" & one named "Last Name". My question is, if I create a column named "Client Name" & want to place the full name in it, how do I do that? Or in other words, how would I edit my code so it would show John Doe in the field as opposed to John in one field & Doe in another? Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Here's how I would do it:
No great difference, but you won't get rogue spaces in the case of anyone with no surname, or only a surname... Just a thought.
<?php
echo "<td>", trim($row['fname'] ." ". $row['lname']), "</td>";
?>
No great difference, but you won't get rogue spaces in the case of anyone with no surname, or only a surname... Just a thought.
ASKER