Vinsanity Posted January 29, 2007 Share Posted January 29, 2007 i would like to knw how can i show few words(dynamic from DB) and when click on it then i will bring us to the details page of it... do i need to pass the variable or id??? can anyone help me? Quote Link to comment https://forums.phpfreaks.com/topic/36152-display-the-details/ Share on other sites More sharing options...
chronister Posted January 29, 2007 Share Posted January 29, 2007 If I understand you correctly, you want a few words of the paragraph and then a [Read More] type link.I may be off base here, but I have done this by pulling the paragraph out of the db and then using an explode function to break each sentence into an array and then display the first sentence.There may be an easier way to do it, but this works pretty good. You can explode on a period to get sentences, or on ' ' whitespace to break it down into each word, then simply echo the number of words you want from the array. Quote Link to comment https://forums.phpfreaks.com/topic/36152-display-the-details/#findComment-171682 Share on other sites More sharing options...
Vinsanity Posted January 30, 2007 Author Share Posted January 30, 2007 anybody able to provide me the code???? Quote Link to comment https://forums.phpfreaks.com/topic/36152-display-the-details/#findComment-172402 Share on other sites More sharing options...
Jessica Posted January 30, 2007 Share Posted January 30, 2007 No, you have to start somewhere, and we'll help you when you get stuck. Where are you stuck?You know how to get the words out of the database? If so, use a function like substr to get the first X chars. Quote Link to comment https://forums.phpfreaks.com/topic/36152-display-the-details/#findComment-172406 Share on other sites More sharing options...
JasonLewis Posted January 30, 2007 Share Posted January 30, 2007 here is some basic code using the substr like jesirose said. BASIC code. look at it. dont copy paste it. write it out yourself. think about it. :) sorry jesirose i am giving the OP some code![code=php:0]$full_news = "Hello! This is some news (it dosnt have to be news) that will be cut down then a link to read me would be displayed. This is so cool.";if(strlen($full_news) > 25){ //25 is the amount of characters to show.$short_news = substr($full_news, 0, 25)."... <a href='link/to/full/news.php'>[read more]</a>";}echo $short_news;[/code]just a small example. Quote Link to comment https://forums.phpfreaks.com/topic/36152-display-the-details/#findComment-172416 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.