Page 1 of 1

trim function not working

Posted: Fri Jun 14, 2002 9:25 am
by mhillman
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>";

Posted: Fri Jun 14, 2002 9:32 am
by twigletmac
Try,

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());
and change

Code: Select all

$fullname = $fullname&#1111;'fullname'];
to

Code: Select all

$fullname = $row&#1111;'fullname'];
It's easier to help if you tell us what's going wrong and what the error messages are (if there are any).

Mac

the problem is:

Posted: Fri Jun 14, 2002 9:39 am
by mhillman
when the page displays, I see:

, firstname

instead of
fullname, firstname

I will try your modifactions. thanks for the quick reply

solved

Posted: Fri Jun 14, 2002 9:46 am
by mhillman
I just changed
$fullname = $fullname ["fullname']
to
$fullname = $row['fullname'];

:oops: Thats what's known as a "duhh!"

Thanks for your quick help.