+ Reply to Thread
Results 1 to 3 of 3

Thread: Adding to php code
      
   

  1. #1
    dannysheps@hotmail.com is offline Second Lieutenant
    Join Date
    Feb 2008
    Posts
    138

    Default 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

  2. #2
    dannysheps@hotmail.com is offline Second Lieutenant
    Join Date
    Feb 2008
    Posts
    138

    Default 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?

  3. #3
    Watdaflip's Avatar
    Watdaflip is offline Major General
    Join Date
    Sep 2005
    Location
    Cincinnati, Ohio
    Posts
    2,119

    Default 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

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49