how to give content limit

Reply

Join Date: Jun 2008
Posts: 47
Reputation: punithapary is an unknown quantity at this point 
Solved Threads: 0
punithapary punithapary is offline Offline
Light Poster

how to give content limit

 
0
  #1
Jul 14th, 2009
hi,
I am creating code for registration form with description field and then i am trying to display all vales using table fields i gave td width as 50 wen i am displaying description if its having huge content its not taking limit its gets expanded but i want like this that huge content gets adjusted within the td i dont want expand it can anyone help about this

thanks in advance
Punitha pary
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 54
Reputation: ryuslash is an unknown quantity at this point 
Solved Threads: 10
ryuslash's Avatar
ryuslash ryuslash is offline Offline
Junior Poster in Training

Re: how to give content limit

 
0
  #2
Jul 14th, 2009
Are you saying that you would like the data in a <TD> tag not to expand when you enter a lot of data into them?

if so you might want to try <td style="overflow: scroll;">?
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 94
Reputation: sikka_varun is an unknown quantity at this point 
Solved Threads: 11
sikka_varun's Avatar
sikka_varun sikka_varun is offline Offline
Junior Poster in Training

Re: how to give content limit

 
0
  #3
Jul 14th, 2009
You can also try to limit the content of the description.

eg:
  1. <td><?php echo substr(0,100,$desc)."...";

This will show only first 100 characters of the description.
VâRûN
---Happy to Help---
sikka_varun@yahoo.com
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 4
Reputation: kamran_FrizCon is an unknown quantity at this point 
Solved Threads: 1
kamran_FrizCon's Avatar
kamran_FrizCon kamran_FrizCon is offline Offline
Newbie Poster

Re: how to give content limit

 
0
  #4
Jul 14th, 2009
  1. //try out this function
  2.  
  3. function limit_words($text, $limit) {
  4. $text = strip_tags($text);
  5. $words = str_word_count($text, 2);
  6. $pos = array_keys($words);
  7. if (count($words) > $limit) {
  8. $text = substr($text, 0, $pos[$limit]) . ' ...';
  9. }
  10. return $text;
  11. }
  12.  
  13.  
  14.  
  15. //in html while display description
  16.  
  17. <td align="left">
  18. <?
  19. $text = strip_tags($row["description"]);// data from database field description
  20.  
  21. if (strlen($text) <= 150)
  22. {
  23. echo $text;
  24. }
  25. else
  26. {
  27. echo limit_words($text, 150,50); //here set limit as much as u want
  28. }
  29. ?>
  30. </td>
Last edited by peter_budo; Jul 15th, 2009 at 7:24 am. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 47
Reputation: punithapary is an unknown quantity at this point 
Solved Threads: 0
punithapary punithapary is offline Offline
Light Poster

Re: how to give content limit

 
0
  #5
Jul 15th, 2009
Hi,
I tried this but its showing limited charaters only but i want to show all text with in the td that means hole text will display in td with i the width.i dont want any scroll bar in down.

Originally Posted by sikka_varun View Post
You can also try to limit the content of the description.

eg:
  1. <td><?php echo substr(0,100,$desc)."...";

This will show only first 100 characters of the description.
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 54
Reputation: ryuslash is an unknown quantity at this point 
Solved Threads: 10
ryuslash's Avatar
ryuslash ryuslash is offline Offline
Junior Poster in Training

Re: how to give content limit

 
0
  #6
Jul 15th, 2009
Well then I'd say either set the width of the TD ( <td style="width: 123px;">text</td> ) or use the overflow property ( <td style="overflow: scroll;">text</td> )
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the PHP Forum
Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC