I have a MYSQL database table with some text fields. I have these fields (or the text in it rather) being output to a php page. The text field is of the type "longtext".
How do I truncate the text displayed when it is being browsed by someone?
For exmple, say the text field in the database has "abcdefghijklmnopqrstuvwxyz". Yet when someone is trying to view it, only the "abcdefg" text is displayed.
__________________________________
SkrekLAN Technologies
www.skreklan.com






Greg K posted this at 17:22—8th December 2004.
He has: 1,601 posts
Joined: Nov 2003
In your SQL query itself you can do the following:
$query = "SELECT LEFT(fieldname,7) FROM table";
In the server side script itself, assuming the data you want to truncate is in variable:
in PHP, substr(variable,0,7);
in ASP, not sure, but if it's like VB, left(variable,7)
-Greg
[This space intentionally left blank]
Cool Geek Supplies: www.ThinkGeek.com
mjs416 posted this at 17:27—8th December 2004.
They have: 127 posts
Joined: Dec 2003
Splendid. Thank you very much. =)
openmind posted this at 18:22—8th December 2004.
He has: 943 posts
Joined: Aug 2001
or in ColdFusion:
#Left(variable, 7)#
just wanted to round off the choices!
Cheers,
Phil
[b]HelmStore.com
UK Distributor of HELM Licenses
Suppliers of SmarterTools, Backup for Workgroups licenses and much, much more![/b]