Display first two Paragraphs
I would like to display the first two paragraphs of text from my database. Each paragraph is surrounded by <p></p> tags.
Can someone point me in the right direction please?
I would like to display the first two paragraphs of text from my database. Each paragraph is surrounded by <p></p> tags.
Can someone point me in the right direction please?
found this through google, should be helpful:
http://www.daniweb.com/web-development/php/threads/411921/extracting-the-first-2-paragraph
I had already looked at this, but struggled to see how I could get it to work...
this is what I tried;
<?php $str = $row_newsRS['newsContent'];
$pattern="/(<p[^>]*>(.*)<\/p>){2}/isU";
preg_match($pattern,$str,$matches);
echo htmlentities($matches[0]); ?>
that should work. i just tried a test of:
<?php
$row_newsRS['newsContent'] = "<p>This is one</p><p>This is two</p><p>This is three</p>";
$str = "<p>This is one</p><p>This is two</p><p>This is three</p>";
$pattern="/(<p[^>]*>(.*)<\/p>){2}/isU";
preg_match($pattern,$str,$matches);
echo htmlentities($matches[0]);
?>
and got the desired result.
I changed it to;
<?php
$pattern="/(<p[^>]*>(.*)<\/p>){2}/isU";
preg_match($pattern,$row_newsRS['newsContent'],$matches);
echo htmlentities($matches[0]);
?>
Im now getting - Notice: Undefined offset: 0 in /home/rsheep/public_html/evergreen/news.php on line 168
Im guessing that this is because this code is in a repeat region...
probably $row_newsRS['newsContent'] has a blank value when that error occurs.
this is not really something supported by the WebAssist extensions, if you need further help troubleshooting, I suggest signing up for a premiere support appointment.
Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.
These out-of-the-box solutions provide you proven, tested applications that can be up and running now. Build a store, a gallery, or a web-based email solution.