Jump to content

Recommended Posts

Not even sure what Im looking for, spent the last half hour on google, no luck.

 

What im looking for is how to tourniquet the output from my search query to limit the characters in my table.

 

Basically, say you have a column that has tons of text in it.  When it displays in its cell, I want to limit the number of characters that gets displayed.  Essentially just show the first 10 works.  Users will have to click a link to view all the text from that record.

 

What would I be looking to do to make this happen?

Link to comment
https://forums.phpfreaks.com/topic/117880-tourniquet-table-data/
Share on other sites

if you only want to view the truncated data you can query it out truncated using the substr function in mysql

 

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

 

 

Alternatively if the entire string length is of importance in that output at a different point then use the php function substr

 

http://us2.php.net/substr

 

to break it down

 

 

You always want to query the exact amount of data you need nothing more and nothing less.

 

my statement was purely on what your query should do not on your output.

 

If you want the whole string to be used any time then by all means pull it all out and format it using php functions.

 

However if you want to follow good habits leaving the garbage (in terms of the use at hand) in the table and pulling what you want out then the mysql substr is a better option

 

 

We'd need to see some code to help you out

Thats the problem, I have no clue where to even start for the code.

 

I think I might just set a limit on the text entered.  Thinking about it now, Crayon brings up a good point.

 

Either

a) limit the data entered so users are forced to cut out useless data

b) show them what they entered, save them an extra click which, I guess, does in fact waste time.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.