Zergman Posted August 2, 2008 Share Posted August 2, 2008 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? Quote Link to comment https://forums.phpfreaks.com/topic/117880-tourniquet-table-data/ Share on other sites More sharing options...
cooldude832 Posted August 2, 2008 Share Posted August 2, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/117880-tourniquet-table-data/#findComment-606343 Share on other sites More sharing options...
Zergman Posted August 2, 2008 Author Share Posted August 2, 2008 So if I understand you right, if I want my users to be able to view all the text, then I need to query for all of it. Am I getting that right? Quote Link to comment https://forums.phpfreaks.com/topic/117880-tourniquet-table-data/#findComment-606348 Share on other sites More sharing options...
.josh Posted August 2, 2008 Share Posted August 2, 2008 Yes. Quote Link to comment https://forums.phpfreaks.com/topic/117880-tourniquet-table-data/#findComment-606351 Share on other sites More sharing options...
Zergman Posted August 2, 2008 Author Share Posted August 2, 2008 Gotcha, thanks for the heads up. Are there any other alternatives? I just want to prevent my results table from looking like garbage if there is lots of text. Quote Link to comment https://forums.phpfreaks.com/topic/117880-tourniquet-table-data/#findComment-606355 Share on other sites More sharing options...
.josh Posted August 2, 2008 Share Posted August 2, 2008 I guess it kind of depends on your specific situation. I mean, there really isn't a whole lot to the proverbial "blahbblahblah read more..." thing. Quote Link to comment https://forums.phpfreaks.com/topic/117880-tourniquet-table-data/#findComment-606360 Share on other sites More sharing options...
cooldude832 Posted August 2, 2008 Share Posted August 2, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/117880-tourniquet-table-data/#findComment-606361 Share on other sites More sharing options...
Zergman Posted August 2, 2008 Author Share Posted August 2, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/117880-tourniquet-table-data/#findComment-606362 Share on other sites More sharing options...
cooldude832 Posted August 2, 2008 Share Posted August 2, 2008 A is always right you never need to store "junk" if you aren't going to use it ever. If the full length of a string is useless why even enter it. Again you gotta have some code written if you are in the echoing out part Quote Link to comment https://forums.phpfreaks.com/topic/117880-tourniquet-table-data/#findComment-606370 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.