Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How only show first n characters of field when fields are long

Community Beginner ,
Jun 03, 2009 Jun 03, 2009

I used to have a document on how to do this but lost it.

How do I specify for a field to display the first so many characters in a given field when the field is too long to display in a table?

TOPICS
Server side applications
644
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 03, 2009 Jun 03, 2009

You would use a string function, probably something like Left() but it depends on the language you are using (which you did include in your post).

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 03, 2009 Jun 03, 2009

Sorry, I'm using PHP, and MySQL.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 03, 2009 Jun 03, 2009
LATEST

sjurick wrote:

Sorry, I'm using PHP, and MySQL.

It depends if you want to either truncate the results from the select statement in the script,  or limit what is being returned by the select. You can use the php substr function

http://www.php.net/manual/en/book.strings.php

or the SQL Left() functions

http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_left

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines