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

PEAR Email Attachment w/ $gpg
I have no issues with this code if I take out the attachement section and include the info in the em

$variable $variables type question
I need to be able to designate an array element dynamically, so I thought to use a variable variable

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

login from external site
Hi my new experience begins, Now what i am trying to do is i make three pages, login.php logout.php

using variables in another page
I have a test database set up on localhost. I have a form that I can type a name into, hit the butto

updating a single value to multiple non consecutive rows
I need to update the same value to multiple non consecutive rows. I need to add an experation date t

generating random codes
Hi guys n gals,

I have a requirement to generate 250,000 unique codes...

These codes a

ScriptResource.axd gives an error on fresh install of ASP.NET Ajax 1.0
Hello,I have a fresh install of Microsoft ASP.NET Ajax 1.0. When I create an Ajax enabled website in

url- go to webpage
i have an input text field and submit button.

how do i make the url entered into the textfiel

need help with mail()
hi i want to send an email with attaching pdf file using php. i have the following script but the pr

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