1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Show a sample of an article, but not the whole thing. W/ PHP & MySQL and/or Jscript

Discussion in 'PHP' started by Arson, Aug 7, 2007.

  1. #1
    I have seen sites do it before, but never could figure out how..

    I am wondering how to make an article stop after a certain amount of characters and then end in ..., so that I can put a link to the full article.

    Eg. This article is an article about articles...

    Pulled from the database..

    Link under it to a new page, with the full article like so...

    This article is an article about articles that read articles about articles reading articles.

    Is there any way to do this with PHP, MySQL, or Javascript?
     
    Arson, Aug 7, 2007 IP
  2. xdimension

    xdimension Peon

    Messages:
    180
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #2
    are you using article script? usually the script will provide that feature. But if you ask about the php code, it will be very easy, just use substr function, see http://www.php.net/substr
     
    xdimension, Aug 7, 2007 IP
    Arson likes this.
  3. mhuggins

    mhuggins Peon

    Messages:
    39
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    With PHP, you can extract part of a string with the substr function. With MySQL, I believe you can use the LEFT function.
     
    mhuggins, Aug 8, 2007 IP
    Arson likes this.
  4. Arson

    Arson Well-Known Member

    Messages:
    622
    Likes Received:
    27
    Best Answers:
    0
    Trophy Points:
    120
    #4
    Thanks for the help :)
     
    Arson, Aug 8, 2007 IP