SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Wizard
    Join Date
    May 2002
    Posts
    1,370
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    abbreviating echoes

    This appears from a varchar column and appears within a repeat region.

    I need to keep all results to the same-width, first 60 characters only followed by ... // for a 'continuance' symbol

    <?php echo $row_Cal['title']; ?>

    Is this done with 'trim' or with 'substr' and how might it look?
    (how can I add the "..." to substr?)

  2. #2
    SitePoint Enthusiast
    Join Date
    Jan 2005
    Location
    UK
    Posts
    30
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try this:
    PHP Code:
    $value substr($row_Cal['title'], 060);
    $value .= "...";
    echo 
    $value

  3. #3
    Mlle. Ledoyen silver trophy seanf's Avatar
    Join Date
    Jan 2001
    Location
    UK
    Posts
    7,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by datadriven
    Is this done with 'trim' or with 'substr' and how might it look?
    It should be done in your query. Are you using MySQL?

    Sean
    Harry Potter

    -- You lived inside my world so softly
    -- Protected only by the kindness of your nature

  4. #4
    SitePoint Wizard
    Join Date
    May 2002
    Posts
    1,370
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    bfsog, thank you. works nicely.

    seanf, yes, mysql, but you kind of lost me.
    How could display results be controlled by the query?

    vbmenu_register("postmenu_2308947", true);

  5. #5
    SitePoint Addict
    Join Date
    Feb 2004
    Location
    belfast
    Posts
    386
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    MySQL allows you to only take the fist X number of characters from a string. You do this using the LEFT() function:

    E.g.

    Code:
    SELECT id, name, LEFT(comments, 25) FROM comments ORDER BY cdate DESC LIMIT 5;
    So that selects the ID, Name and the first 25 chars from the comments colums from the comments table - orders them by the cdate (more than likely create date) and returns 5 results in descending order, based on the cdate.

    Regards,

    Ronan

  6. #6
    Mlle. Ledoyen silver trophy seanf's Avatar
    Join Date
    Jan 2001
    Location
    UK
    Posts
    7,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by ronanmagee
    MySQL allows you to only take the fist X number of characters from a string. You do this using the LEFT() function:


    Sean
    Harry Potter

    -- You lived inside my world so softly
    -- Protected only by the kindness of your nature


Bookmarks

Posting Permissions

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