Loading only an amout of characters

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
Jay Eff
Forum Newbie
Posts: 20
Joined: Sat Oct 26, 2002 11:35 am

Loading only an amout of characters

Post by Jay Eff »

How do I take make a mySQL query that only loads a set amout of variables from a field?
Example: If I have a title for a forum post, and only want to display the first 20 letters of the title on the print out of posts.

Please help, I can't find it anywhere. :?
JPlush76
Forum Regular
Posts: 819
Joined: Thu Aug 01, 2002 5:42 pm
Location: Los Angeles, CA
Contact:

Post by JPlush76 »

check out the function substr()
(SUBSTRING)

Code: Select all

<?php

// TAKE THE OLD FIELD AND START AT THE FIRST CHARACTER AND JUST GIVE ME THE FIRST 20 AFTER THAT
$field = substr($oldfield, 0,20);

?>
Jay Eff
Forum Newbie
Posts: 20
Joined: Sat Oct 26, 2002 11:35 am

Post by Jay Eff »

thank you a lot
Post Reply