| | |
how to give content limit
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Jun 2008
Posts: 47
Reputation:
Solved Threads: 0
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
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
You can also try to limit the content of the description.
eg:
This will show only first 100 characters of the description.
eg:
php Syntax (Toggle Plain Text)
<td><?php echo substr(0,100,$desc)."...";
This will show only first 100 characters of the description.
php Syntax (Toggle Plain Text)
//try out this function function limit_words($text, $limit) { $text = strip_tags($text); $words = str_word_count($text, 2); $pos = array_keys($words); if (count($words) > $limit) { $text = substr($text, 0, $pos[$limit]) . ' ...'; } return $text; } //in html while display description <td align="left"> <? $text = strip_tags($row["description"]);// data from database field description if (strlen($text) <= 150) { echo $text; } else { echo limit_words($text, 150,50); //here set limit as much as u want } ?> </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.
•
•
Join Date: Jun 2008
Posts: 47
Reputation:
Solved Threads: 0
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.
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)
<td><?php echo substr(0,100,$desc)."...";
This will show only first 100 characters of the description.
![]() |
Similar Threads
- What's the HARDEST program you've written? (Computer Science)
- Save WinXP (Geeks' Lounge)
- Trying to copy data from one form to another form (Visual Basic 4 / 5 / 6)
- Gray Reputation (DaniWeb Community Feedback)
- Sending HTML email via PHP mail function (PHP)
- Google sitemap page weight (Search Engine Optimization)
- Javascript form managment on the fly! (JavaScript / DHTML / AJAX)
- Forums / Websites? (Social Media and Online Communities)
Other Threads in the PHP Forum
- Previous Thread: wht does this mean in php ?
- Next Thread: Css problem
| Thread Tools | Search this Thread |
Tag cloud for PHP
.htaccess access ajax apache api array back beginner binary broken cakephp checkbox class cms code cron curl database date directory display download dynamic echo email error file files filter folder form forms function functions gc_maxlifetime google host href htaccess html image include insert integration ip java javascript joomla limit link login loop mail memmory memory menu mlm mod_rewrite multiple mysql navigation oop parse parsing paypal pdf php problem query radio random recursion regex remote script search server sessions sms snippet soap source space sql structure syntax system table thesishelp tutorial update upload url validation validator variable video web xml youtube





