Adding to php code

Collapse
X
Collapse
+ More Options
Posts
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • dannysheps@hotmail.com
    Second Lieutenant

    • Feb 2008
    • 138

    Adding to php code

    Hello
    i have part of a PHP code that prints on the screen something from my DATABASE
    echo $row['posting_discription'];

    i wanted to know if i can add something to this line of code to make the posting discription (usualy more then 20 words) to show only 4-6 words and "..." after and it will show as a link to another page(or even the same one) with the full posting ( like in www.craigslist.com)

    thanks alot
  • dannysheps@hotmail.com
    Second Lieutenant

    • Feb 2008
    • 138

    #2
    Re: Adding to php code

    more...
    can i actialy create a design via PHP code
    how i can add something after the echo that will add color for text and stuff?

    Comment

    • Watdaflip
      Major General

      • Sep 2005
      • 2116

      #3
      Re: Adding to php code

      The easier way is to cut it off after a character limit, to do that do something like..

      PHP Code:
      $max_char 50;
      if(
      strlen($row['posting_discription']) >= $max_char)
      {
      $row['posting_discription'] = substr($row['posting_discription'], 0$max_char)."...";

      That will cut it off at 50 characters and add ... to the end.

      As far as formatting the color, you just add html to the strings... like
      PHP Code:
      $sometext "<span style=\"color: #FF0000\">Red text</span>"

      Register/Login Script
      Do you use a Password Protected Directory? Need a way to allow users to make their own account, try my .htaccess Login Script

      Comment

      Working...