943,648 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 1536
  • PHP RSS
Jul 14th, 2009
0

how to give content limit

Expand Post »
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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
punithapary is offline Offline
48 posts
since Jun 2008
Jul 14th, 2009
0

Re: how to give content limit

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;">?
Reputation Points: 32
Solved Threads: 13
Junior Poster in Training
ryuslash is offline Offline
57 posts
since Jul 2009
Jul 14th, 2009
0

Re: how to give content limit

You can also try to limit the content of the description.

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

This will show only first 100 characters of the description.
Reputation Points: 11
Solved Threads: 12
Junior Poster in Training
sikka_varun is offline Offline
94 posts
since Dec 2008
Jul 14th, 2009
1

Re: how to give content limit

php Syntax (Toggle Plain Text)
  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.
Reputation Points: 10
Solved Threads: 4
Light Poster
kamran_FrizCon is offline Offline
33 posts
since Jul 2009
Jul 15th, 2009
0

Re: how to give content limit

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.

You can also try to limit the content of the description.

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

This will show only first 100 characters of the description.
Reputation Points: 10
Solved Threads: 0
Light Poster
punithapary is offline Offline
48 posts
since Jun 2008
Jul 15th, 2009
0

Re: how to give content limit

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> )
Reputation Points: 32
Solved Threads: 13
Junior Poster in Training
ryuslash is offline Offline
57 posts
since Jul 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: wht does this mean in php ?
Next Thread in PHP Forum Timeline: Css problem





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC