close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Display first two Paragraphs

Thread began 1/22/2014 9:40 am by Daryl | Last modified 1/22/2014 1:50 pm by Jason Byrnes | 638 views | 5 replies |

DarylBeta Tester

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?

Sign in to reply to this post

Jason ByrnesWebAssist

found this through google, should be helpful:
http://www.daniweb.com/web-development/php/threads/411921/extracting-the-first-2-paragraph

Sign in to reply to this post

DarylBeta Tester

I had already looked at this, but struggled to see how I could get it to work...

this is what I tried;

php:
<?php   $str $row_newsRS['newsContent'];

$pattern="/(<p[^>]*>(.*)<\/p>){2}/isU";
preg_match($pattern,$str,$matches);
echo 
htmlentities($matches[0]); ?>
Sign in to reply to this post

Jason ByrnesWebAssist

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.

Sign in to reply to this post

DarylBeta Tester

I changed it to;

php:
<?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...

Sign in to reply to this post

Jason ByrnesWebAssist

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.

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

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.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...