patheticsam Posted December 16, 2012 Share Posted December 16, 2012 Hi! I'm new to php and I have a really simple question.. I have some text stored in a MySQL database and i'm outputting the texts like this : $data = mysql_query("SELECT * FROM lva_artistes ORDER by RAND() LIMIT 0,2") or die(mysql_error()); while($info = mysql_fetch_array( $data )) { echo $info['text']; } Since it's a long text I want to know if there's a way to output only the first X characters (ex: only de first 500 characters)... If anyone can point me to a tutorial or the right function it would be really appreciated.. Thanks!! Quote Link to comment https://forums.phpfreaks.com/topic/272058-simple-question-with-phpmysql-output/ Share on other sites More sharing options...
Pikachu2000 Posted December 16, 2012 Share Posted December 16, 2012 Either with the MySQL function SUBSTRING(), or with the PHP function substr. Quote Link to comment https://forums.phpfreaks.com/topic/272058-simple-question-with-phpmysql-output/#findComment-1399680 Share on other sites More sharing options...
patheticsam Posted December 16, 2012 Author Share Posted December 16, 2012 Got it, works perfectly....Thanks!!! Quote Link to comment https://forums.phpfreaks.com/topic/272058-simple-question-with-phpmysql-output/#findComment-1399681 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.