0
How can i limit the number of characters from my post description on a page.
Please someone should help me, i want to limit the number of characters from my post description. I need a code to limit the number of characters that should appear on a page after a SELECT FROM post.
1 Respuesta
0
try this
SELECT concat(SUBSTRING("this is some text coming from database", 1, 20),'...') AS description from post;
Here
SUBSTRING(string, start, length)
---------------------------------------------------------------------------------------------------------
Much better sql
SELECT concat(SUBSTRING(SUBSTRING(description,1,50),1,LENGTH(SUBSTRING(description,1,50)) - LOCATE(' ', REVERSE(SUBSTRING(description,1,50)))+1),'..Read more') FROM post;
where 50 is the limit.