|
-
Jul 29th, 2007, 09:57 AM
#1
Thread Starter
Addicted Member
Help with limiting text from DB
Hey,
I have developed a simple from system that allows users to input some comments. This all works fine, however when I try to retrieve the comments I only want to display 100 characters.
I am new to PHP, but was wondering if there is a string function that will let me take the data from a table in my database and then only display 100 characters followed by "..." afterwards.
Also I have thought of a potential problem... if someone enters less than 100 characters I only want to show the amount they have entered.
can anyone help?
-
Jul 29th, 2007, 11:49 AM
#2
Re: Help with limiting text from DB
This is something that should be done in your query rather than the application code. If you are always going to truncate the query result, it makes no sense to have to return all of the data from the database server.
If you're using MySQL, have a look at the MySQL String Functions—in particular, LEFT() will do what you need.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|