Re: FW: [PHP] Help please!

From: Date: Fri, 10 Nov 2000 11:38:38 +0000
Subject: Re: FW: [PHP] Help please!
Groups: php.general 
Request: Send a blank email to php-general+get-24645@lists.php.net to get a copy of this message
Addressed to: "craig girard" <craig@netric.com> "Php-General" <php-general@lists.php.net> Wee Chua [mailto:Chua@mail.interclean.com] ** Reply to note from "craig girard" <craig@netric.com> Thu, 9 Nov 2000 11:55:19 -0500 No, it is a database function in MySQL. I have not tried using the + operator in strings in MySQL, but I don't think it works. See below for an answer to the original question. > > Wee, > > I have just started using PHP, but have been using web languages for 4 > years. Is the CONCAT fucntion you are trying to use a PHP function? > Anyway what you can do, and looks like you are trying to do, is do it in > SQL, therefore try this syntax... > > SELECT fname + ' ' + lname AS fullname FROM tablename > > hope this helps > > Craig Girard > > > -----Original Message----- From: Wee Chua > [mailto:Chua@mail.interclean.com] Sent: Thursday, November 09, 2000 11:30 > AM To: MySQL (E-mail); PHP (E-mail) Subject: [PHP] Help please! > > > Hi all, I have a problem for using concat fname and lname to become > fullname field from the query, is it possible I could do the string > comparison after concat funtion, thanks a lot. I have tried the example > below but it didn't work. Could anyone tell me is there any errors in my > codes or could I do it in different way for not repeatedly displaying > fullname? Thank you very much. > > for example, > > $result=mysql_query("SELECT concat(fname,' ',lname) fullname, ... FROM > tablename",$db); > > $data=mysql_fetch_row($result); $data=$row('fullname'); > > if ($data!==$old) { > echo "$data"; > $old=$data; } > else { echo " "; > } > SELECT concat(fname,' ',lname) AS fullname, Data FROM tablename ^^ I believe you need an AS keyword here. Also to read the result I would do something like this: $old = ''; while( list( $FullName, $Data ) = mysql_fetch_row( $Result )) { if( $Data != $old ) { echo $Data; $old = $Data; } else { echo ''; } } Rick Widmer Internet Marketing Specialists www.developersdesk.com

« previous php.general (#24645) next »