Results 1 to 2 of 2
Thread: MySQL select first paragraph
May 22, 2003, 11:42 #1
MySQL select first paragraph
I have a story lead on my front page that I just want to display the author name and the first paragraph of that authors most recent story. Should I just create a field in my database that contains the lead. Or is there a way to select just the first paragraph of the article.
May 22, 2003, 16:23 #2
- Join Date
- Mar 2002
- 0 Post(s)
- 0 Thread(s)
You can use mysql substring(text, start, end) if you know how many characters to extract.
SELECT Substring(articletext, 0, 20) AS abstract FROM yourtable WHERE authorid = 1 ORDER BY publisheddate LIMIT 1;
$text = '<p>blasdasdasdsad</p><p>asdsad</p>';
echo substr($text, 0, strpos('</p>', text));