Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Limit string output size from a database record 1

Status
Not open for further replies.

martinb7

Programmer
Jan 5, 2003
235
GB
Hi, how would you go about limiting the output string size from a record??

Say i have a string of

Welcome to WebRevolt, the Next Web Revolution, how could i limit that to a 100 characters then add '... more' after it??

its for my news poster so I dont have massive news articles on the homepage

any ideas

thanx


Martin

Computing help and info:

 
Code:
<?php

$sql="SELECT CONCAT(SUBSTRING(field_title,1,100),'...') FROM news_table where ID=new_id_to_search";
$qry=mysql_query($sql) or die (mysql_error());
..
 
or using only php:

Code:
<?php

echo substr($field_news,1,100) . "...";

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top