PhP Mysql query blog latest results

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
gwolff2005
Forum Commoner
Posts: 68
Joined: Sun Apr 05, 2009 10:58 am

PhP Mysql query blog latest results

Post by gwolff2005 »

Hi guys,
I need your help. I have a blog and on a complete different page my homepage. Now what I want to do is that if I post a new post on my blog that the first 35 words of it appear in a layer, and then as well next to it the publish date.
I realized that I would need to create an mysql query which comes up with the last entry,
How can I do that? And then which is probably more complicated how can I tell mysql to give me just 35 words, or can I limit in any way the layer????
I am helpless! I would deeply appreciate if someone could help me!
Thanks!
abushahin
Forum Commoner
Posts: 42
Joined: Wed Nov 25, 2009 12:35 pm
Location: london

Re: PhP Mysql query blog latest results

Post by abushahin »

ok you can retrieve the last id by using

Code: Select all

$lastid = mysql_query( "SELECT last_insert_id()" );
$blogid = mysql_result($lastid,"blog_Id");
thatll retrieve your last insert id, then select using $blogid,
to show only a part of your string using php you can use The Substr () PHP Function
this is written as:

Code: Select all

[b]substr (string, start, optional length);.[/b]
atleast you have a lead now, abu
Post Reply