trim function not working
Posted: Fri Jun 14, 2002 9:25 am
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>";
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>";