Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

echo a paragraph from database and getting substr

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

echo a paragraph from database and getting substr

Postby inoob » Sat Sep 07, 2013 2:28 pm

Queries are already set. I am trying to echo a paragraphs from articles from the mysql database and get sub string of each when they displayed in my pagination script. Would this be correct?:
I have a variable that outputs data. It would be $outputList .= '

Within $outputList variable I am trying to echo out a substring from paragraphs from mysql database.

substr("'. $row['fldInfo'].'", 0, 200);

and to echo it out, would this be correct:

echo substr("'. $row['fldInfo'].'", 0, 200);

This is not working. How do I go around this?
inoob
New php-forum User
New php-forum User
 
Posts: 31
Joined: Tue Nov 06, 2012 12:20 pm

Re: echo a paragraph from database and getting substr

Postby johnj » Sun Sep 08, 2013 2:41 am

try this
Code: Select all
$temp = $row['fldInfo'];
echo substr($temp, 0, 200);
johnj
php-forum Super User
php-forum Super User
 
Posts: 1805
Joined: Thu Mar 10, 2011 5:07 pm

Re: echo a paragraph from database and getting substr

Postby inoob » Sun Sep 08, 2013 5:18 am

Its echoing out:
substr($substr_paragraph, 0, 200);

It's not echoing out the paragraphs.
inoob
New php-forum User
New php-forum User
 
Posts: 31
Joined: Tue Nov 06, 2012 12:20 pm

Re: echo a paragraph from database and getting substr

Postby johnj » Mon Sep 09, 2013 8:09 pm

try this:
Code: Select all
$temp = $row['fldInfo'];
$mysubstr = substr($temp, 0, 200);
echo " Substring is :".$mysubstr;
johnj
php-forum Super User
php-forum Super User
 
Posts: 1805
Joined: Thu Mar 10, 2011 5:07 pm

Re: echo a paragraph from database and getting substr

Postby inoob » Wed Sep 11, 2013 4:55 am

That one worked! :)

Thanks!
inoob
New php-forum User
New php-forum User
 
Posts: 31
Joined: Tue Nov 06, 2012 12:20 pm

Re: echo a paragraph from database and getting substr

Postby inoob » Wed Sep 11, 2013 5:23 am

As well as I used .htmlentities() as well and that also worked.
inoob
New php-forum User
New php-forum User
 
Posts: 31
Joined: Tue Nov 06, 2012 12:20 pm


Return to PHP coding => General

Who is online

Users browsing this forum: Google Feedfetcher and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.