spikypunker Posted June 5, 2009 Share Posted June 5, 2009 Hi guys, i thought this would be really simple but i cant find how to do it. I'm displaying a News panel, with the title and thumbnail of each story shown, i want to display a part of the main content too, but only about 50 characters. Is this possible? Quote Link to comment https://forums.phpfreaks.com/topic/161057-limiting-a-variable-string/ Share on other sites More sharing options...
spikypunker Posted June 5, 2009 Author Share Posted June 5, 2009 sorry i didnt explain that enough, I'm taking the variables from the database, ie $content = result $title = result etc Then i want to go $content = $content MAX CHARACTERS 50 or some such Quote Link to comment https://forums.phpfreaks.com/topic/161057-limiting-a-variable-string/#findComment-849936 Share on other sites More sharing options...
Axeia Posted June 5, 2009 Share Posted June 5, 2009 Question for the sql part of the forum tbh. http://www.1keydata.com/sql/sql-substring.html Quote Link to comment https://forums.phpfreaks.com/topic/161057-limiting-a-variable-string/#findComment-850102 Share on other sites More sharing options...
PFMaBiSmAd Posted June 5, 2009 Share Posted June 5, 2009 You could do this in your query, in php, or in javascript (but I am pretty sure not cleanly using CSS, which is where you posted the question.) Each method has advantages and disadvantages, such as how much data you send to the browser, will you typically need the whole content during the same browser session or not... Which method (query, php, javascript) were you planning on using to get the first x characters of the result and do you always need the full result on the same page or during the same browser session? Quote Link to comment https://forums.phpfreaks.com/topic/161057-limiting-a-variable-string/#findComment-850150 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.