Jump to content

Archived

This topic is now archived and is closed to further replies.

Woodburn2006

Displaying a maximum amount of charachters

Recommended Posts

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...

Share this post


Link to post
Share on other sites
[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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.