Skip to main content
Known Participant
June 3, 2009
Question

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

  • June 3, 2009
  • 1 reply
  • 633 views

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?

This topic has been closed for replies.

1 reply

Participating Frequently
June 3, 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).

SJurickAuthor
Known Participant
June 3, 2009

Sorry, I'm using PHP, and MySQL.

Participating Frequently
June 4, 2009

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