Forum Moderators: coopster

Message Too Old, No Replies

returning a snippet for display from mysql

         

diegomh7

6:08 pm on Jun 25, 2006 (gmt 0)

10+ Year Member



Elo again, so ive got a client wih multiple news articles stored in a database, all i need to do i limit the characters that are dispayed and then make a read more link to the full article.

So, article one is say 400 characters long, on the homepage theres room for 200, i want to show the first two hundred words or characters from that article and then when they click read more it sends the id of the article to the articles.php page and the full article is displayed, i can do everything upto the bit where the charaters from the $text variable are counted and then only the first half of the article is displayed, kind of like a blog or news section really,

should be simple really just grab info from the mysql database and echo it onto the screen, but i dont want the full article, what command or loop am i needing to get the desired result?

help!

Diegomh7

eelixduppy

11:47 pm on Jun 25, 2006 (gmt 0)



Why don't you try:

$first_200 = [url=http://www.php.net/manual/en/function.substr.php]substr[/url]($text,0,200);

Good luck

jatar_k

5:25 am on Jun 26, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



you could also use SUBSTRING(str,pos,len) in your mysql query

[dev.mysql.com...]

you'll have to search the page

diegomh7

12:29 pm on Jul 2, 2006 (gmt 0)

10+ Year Member



PERFECT ONCE AGAIN!

Cheers!