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 unknown amount of results
I am reading a directory and getting a list of folders in the directory, I want to display the folde

How to generate a random array of integers subject to a certain constraint
I am writing a program that asks the user to enter an integer N and then generates a random array of

passing an array of objects after submit
How do I do this? This is what I have tried and it is not working.

<form method="

Querying info from one table based on info in another
Hi, I am currently trying to make a part for my user driven website where one user can subscribe to

Code doesn't print what i wanted it too. Please help!
Hi there,

I wrote this code to mae it so that in the form before it that the user said their

Add_Months not Easy to Understand
Oracle is number 1, very fast and very easy. But....
OK, I think but have a problem, only 1 pro

Echo-ing MySQL content and Keep Formatting?
I have data in my MySQL such as:

QuoteBlah blah

Blah blah

etc
but when i ech

Session login issue
I'm wondering how to fix a problem I'm having with a session-based login system

Say I go to h

Mail Script Problems
I have created a PHP mail script. I am having a problem though. In $body i am trying to put two va

Help! refer to a friend script with captcha code
Hi guys, I am posting on here in desperate need for some help with an ongoing search I have been doi

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