Jump to content

[SOLVED] concat


marcs910

Recommended Posts

I'm looking to concat the first_name and last_name in the Name column in my table. Every way I've tried I have came up short.

 

Any ideas?

 

echo '<table align="center" cellspacing="0" cellpadding="5">

<tr>

<td align="left"><b>Edit</b></td>

<td align="left"><b>Delete</b></td>

<td align="left"><b>Name</b></td>

<td align="left"><b>Email</b></td>

<td align="left"><b>Registration Date</b></td>

</tr>

 

';

 

//Get and print all the records

$bg = '#eeeeee'; //Set the background color

 

while ($row=mysql_fetch_array

($result, MYSQL_ASSOC)) {

 

$bg = ($bg=='#eeeeee' ? '#ffffff' : '#eeeeee'); // Switch the background color.

echo '<tr bgcolor="' . $bg . '">

  <td align="left"><a href="edit_user.php?id=' . $row['user_id'] . '">Edit</a></td>

  <td align="left"><a href="delete_user.php?id=' . $row['user_id'] . '">Delete</a></td>

  <td align="left">' . $row['first_name'] . '</td>

  <td align="left">' .  $row['email'] . '</td>

  <td align="left">' . $row['registration_date'] .  '</td>

  </tr>';

 

  }

echo '</table>';

 

}

Link to comment
https://forums.phpfreaks.com/topic/46328-solved-concat/
Share on other sites

What did you try?

 

Change

<?php
<td align="left">' . $row['first_name'] . '</td>
?>

to

<?php
<td align="left">' . $row['first_name'] .  ' ' . $row['last_name'] . '</td>
?>

 

The above assumes that the last name is in the field "last_name".

 

Ken

Link to comment
https://forums.phpfreaks.com/topic/46328-solved-concat/#findComment-225383
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.