ROCKINDANO Posted March 4, 2009 Share Posted March 4, 2009 Hello all, Well i have a db of stories. and i want to display just part of the story (example first sentence) on one page and then display all the story once they click on the link to read more. any help??? Thanks in advance Quote Link to comment https://forums.phpfreaks.com/topic/147946-solved-display-part-of-a-text-record/ Share on other sites More sharing options...
rhodesa Posted March 4, 2009 Share Posted March 4, 2009 Can you elaborate on what you exactly want? There isn't one answer...SUBSTR() can be used for a fixed number of characters...to do an entire sentance, you will have to find a period in the text, etc here are a list of MySQL string functions too: http://dev.mysql.com/doc/refman/5.1/en/string-functions.html p.s. - are you using PHP? you will most likely have a wider variety of options on your scripting language Quote Link to comment https://forums.phpfreaks.com/topic/147946-solved-display-part-of-a-text-record/#findComment-776497 Share on other sites More sharing options...
ROCKINDANO Posted March 4, 2009 Author Share Posted March 4, 2009 yes i am using php. well its a page that shows a list of stories. this page should show a brief part of the story. for example the first sentence or so. then right after that it has read more as a link. once you click on read more the next page should display that story in its full. Quote Link to comment https://forums.phpfreaks.com/topic/147946-solved-display-part-of-a-text-record/#findComment-776503 Share on other sites More sharing options...
rhodesa Posted March 4, 2009 Share Posted March 4, 2009 well, you can select the entire story from MySQL, then when you display it, use: print substr($row['story'],0,strstr($row['story'],'.')); that should only show the story up to the first period Quote Link to comment https://forums.phpfreaks.com/topic/147946-solved-display-part-of-a-text-record/#findComment-776519 Share on other sites More sharing options...
ROCKINDANO Posted March 4, 2009 Author Share Posted March 4, 2009 well i did that now it doesn't display anything just the title. this is a snippet of where it displays the title, first sentence and the read more link. if(!isset($news_id)) { $query = "SELECT * FROM news ORDER BY news_id DESC"; $result = mysql_query($query); //goes through all records in database and retrieves the need ones. while($r=mysql_fetch_array($result)) { //the format is $variable = $r["nameofmysqlcolumn"]; $news_id=$r["news_id"]; $fulldesc =$r["fulldesc"]; //displays all info only first three print "<p><b style='color:#9F0000'>".$title=$r["title"]."</b><br />"; // print $description=$r["description"]; print substr($row['fulldesc'],0,strstr($row['fulldesc'],'.')); print "… <a href='newsevents.php?news_id={$news_id}'>read more »</a></p>"; }//end while loop }//end if Quote Link to comment https://forums.phpfreaks.com/topic/147946-solved-display-part-of-a-text-record/#findComment-776560 Share on other sites More sharing options...
ROCKINDANO Posted March 4, 2009 Author Share Posted March 4, 2009 i have solved this problem. thank you very much Quote Link to comment https://forums.phpfreaks.com/topic/147946-solved-display-part-of-a-text-record/#findComment-776574 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.