News:

Want to get involved in developing SMF? Why not lend a hand on our GitHub!

Main Menu

Display x amount then .......

Started by Valconeye, January 20, 2004, 08:35:41 AM

Previous topic - Next topic

Valconeye

Im trying to figure out howto display a certian amount of words from a database and if it goes over the amount of words do ... Im sure its pretty easy, but i cant think of it.

Tyris

dunno how you'd withdraw a certain ammount...
but the str commands can do it...
can't remember which one... but go tp php.net and find out... one you can get to start at zero, and stop at x...
so just use that... ;) (sorry I can be more helpful, I'm tired ;))

Shoeb Omar

you're looking for the substring function :)

Jeff Lewis

Grab the fields and then use substr:

$sql = 'SELECT field FROM table';
$request = mysql_query ($sql) or die (mysql_error());
while ($row = mysql_fetch_assoc($request))
{
$string = '"' . substr($row['field'],0,60);
$string .= (strlen($row['field']) > 60 ? '..."' : '"   ');
echo $string;
}
Co-Founder of SMF

Advertisement: