Woodburn2006 Posted August 4, 2006 Share Posted August 4, 2006 when a block of text is returned from a mysql query, is there any way of just displaying the first 40 charachters? so that it would look like this in the web page:this is the first part of the returned res... Quote Link to comment Share on other sites More sharing options...
AndyB Posted August 4, 2006 Share Posted August 4, 2006 [code]$query = "SELECT left(fieldname,40) FROM your_table_name ....";[/code]or, select the whole thing but use the substr() function before displaying the text Quote Link to comment Share on other sites More sharing options...
Woodburn2006 Posted August 4, 2006 Author Share Posted August 4, 2006 how would i use the substr() function? Quote Link to comment Share on other sites More sharing options...
tvdhoff Posted August 4, 2006 Share Posted August 4, 2006 Try:[code]$content=$row["contentFromDB"];$shortContent=substr($content,0,40);[/code]Where '0' is the start character of the string ($content) you are using and '40' is the number of characters that will be outputted. Quote Link to comment 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.