Formatting echo from database


Posted on 16th Feb 2014 07:03 pm by admin

So I have a database that stores First and last names, then echos them back to a website, as of now the entire first and last name echos back (John Smith) I want the last name to just display the last letter and a . (John S.) here's my code for echoing the database

Code: <?PHP
$res = mysql_query("SELECT id, DATE_FORMAT(date, '%M %D %Y') as dt, firstname, lastname, testimonial FROM testimonials ORDER BY date DESC LIMIT 10");

while ($row = mysql_fetch_assoc($res)) {
echo "<p align="right"><i>{$row['firstname']} {$row['lastname']}<br />{$row['dt']}</i></p><br /><br />{$row['testimonial']}<br /><hr width="80%" color="#000000"><br />";
}
?>

No comments posted yet

Your Answer:

Login to answer
222 Like 38 Dislike
Previous forums Next forums
Other forums

if php cookie set, show code...
Hi all.. I need to figure out this little snippet right quick.. seems like it should be easy enough

Keeping track of php uploads
Hello all.

I was looking at the way PHP handles file uploads.
It seems that PHP uses a tem

Beginner PHP code help
Hi I'm new to php but if someone could please read the question below and help it would be great.

listcube issue
Hi
I have a virtual cube ZREMOTE. I use Tcode "listcube" to retrieve contents. I use of the

Optimize Code
Just started getting into the use of cookies. The following code will redirect users to a set URL s

WS-Security PL/SQL Forms
Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - Prod
PL/SQL Release 10.2.0.2.0 - P

Last Weeks sDate and eDate.
sDate - Start Date
eDate - End Date

I need to pull two dates for "Last Week" whi

Dynamically allocating the number of rows in a table based on a variable value
Hi,
I have situation here which i cannot resolve, I have a variable temp which stores the num

User feedback after MySQL query has been executed
Hi all, I've just registered on PHPFreaks because I've got a question that I simply can't work out b

PHP and MySQL Question/Help
I have a MySQL db with all my servers and all their details like server name, IP, OS, RAM etc etc 26

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash