The intent is to show a list of members of a sorority alumni association, by combining their last name when they pledged the sorority and their last name now into a value called "fullname". The display page shows " , firstname", rather than "fullname, firstname"
I am new to php. Can someone please review this code and tell me what I am doing wrong?
$sql = "SELECT id, trim(concat(ln_then,' ',ln_now)) as fullname, firstname
FROM $table_name
ORDER BY fullname
";
$result = @mysql_query($sql,$connection) or die("Couldn't execute query.");
$contact_list = "<ul>";
while ($row = mysql_fetch_array($result)) {
$id = $row['id'];
$firstname = $row['firstname'];
$fullname = $fullname['fullname'];
$fullname = trim($fullname);
$member_list .= "<li><a href=\"show_member_public.php?id=$id\">$fullname, $firstname</a>";
}
$member_list .= "</ul>";
trim function not working
Moderator: General Moderators
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
Try,
and change
to
It's easier to help if you tell us what's going wrong and what the error messages are (if there are any).
Mac
Code: Select all
$sql = "SELECT id, CONCAT(ln_then,' ',ln_now) AS fullname, firstname FROM $table_name ORDER BY fullname";
$result = @mysql_query($sql,$connection) or die('Couldn't execute query.<br />'.mysql_error());Code: Select all
$fullname = $fullnameї'fullname'];Code: Select all
$fullname = $rowї'fullname'];Mac
the problem is:
when the page displays, I see:
, firstname
instead of
fullname, firstname
I will try your modifactions. thanks for the quick reply
, firstname
instead of
fullname, firstname
I will try your modifactions. thanks for the quick reply