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... Link to comment https://forums.phpfreaks.com/topic/16532-displaying-a-maximum-amount-of-charachters/ 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 Link to comment https://forums.phpfreaks.com/topic/16532-displaying-a-maximum-amount-of-charachters/#findComment-69076 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? Link to comment https://forums.phpfreaks.com/topic/16532-displaying-a-maximum-amount-of-charachters/#findComment-69077 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. Link to comment https://forums.phpfreaks.com/topic/16532-displaying-a-maximum-amount-of-charachters/#findComment-69084 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.