Page 1 of 1

PhP Mysql query blog latest results

Posted: Sat Nov 21, 2009 1:55 pm
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!

Re: PhP Mysql query blog latest results

Posted: Wed Nov 25, 2009 4:23 pm
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