[thelist] PHP show first 10 words of MySQL field

Paul Bennett paul at teltest.com
Wed Aug 27 21:39:35 CDT 2003


Austin Harris wrote:

>Sorry for the poor title but I am not sure how to describe what I want to do
>concisely...
>
>I have a text field in a db and want to show on one page just the first 20
>words, (more or less) of that field before putting a "view more" link.
>
>Being relatively new to PHP I am not sure what sort of function I need to
>use, searching is tricky without being able to state the problem concisely!
>
>I am guessing I want to count the words, (or characters) and set a cut off
>limit.
>
>All help very much appreciated.
>
>Austin
>
>  
>
# take your original db string and get the first (say) 200 characters
$shortString =  substr ( $originalString, 0, 200);
That should get you started?

-- 
 ------------------------------
	Paul Bennett						
	Internet Developer				
	Teltest Electronic Design		
 ------------------------------			
Email: paul at teltest.com				
Phone: 64 4 237 4557					
Web: http://www.teltest.com		
Wap: http://wap.teltest.com			




More information about the thelist mailing list