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");
Did you know?Explore Trending and Topic pages for more stories like this.

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

Displaying data from MySql a different way
Hi all,
I'm pretty new to php and MySql and have hit a problem.

I am able to display data

Pagination
Hi All,

I think I'm finally getting somewhere with pagination!

I can now submit a quer

Simple PHP/Java Help..
Hi,
I'm trying to build a little program to do with calculating postage. Unfortunately i haven't

Unable to display contents in Second Drop Down Box
Hi All,

What I am trying to do is 2 dependent drop down boxes and when user selects su

preg-match with a string and numbers
Hi, I can't get the expression to work for my preg_match, what I'd like is for it to match the strin

How to show next and prev records
Hi all,

Sorry if this is simple, i'm very new to php, well, any programming language actually

Parse String
I need to parse the string below into three variables. How would I do that?

john + 10/20/2008

PHP page is blank
Hi Everyone,

I have a site in which I am able to open the first PHP webpage in my browser but

Checkbox info wont include in Mailto
Hey, im new to php.
Basically I have made a form to request which type of job(s) are needed, whic

how to get values from $_Post with onchange="form.submit();"?
Hi, I have a form that submit to itself with a file upload field and two other hidden field values.<

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