SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot
    Join Date
    Jul 2000
    Posts
    132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi.
    I am trying to query the mysql db, and get the first 30 characters of a field.
    & Basically, its not working.

    The code in question:
    Code:
    $result = mysql_query("SELECT id, active, keyword, LEFT(adtitle,20), impressions, clickthroughs from adverts WHERE advertiser='$advertiserid' order by $mysql_order desc LIMIT $offset, $limit  " );
    
    if (mysql_num_rows($result) == 0) { 
    
    echo ("
    //no adverts in your account message
    ");
    
    } 
    
    while ( $details = mysql_fetch_array($result) ) {
    
    $advertid = $details["id"];
    $keyword = $details["keyword"];
    $adtitle = $details["adtitle"];
    $impressions = $details["impressions"];
    $clickthroughs = $details["clickthroughs"];
    $active = $details["active"];
    Right, well, when i do the query, everything works apart from 'adtitle'.
    Does anyone know how to make it show up?

    Thanks.
    -aj


  2. #2
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes you must assign an alias to your LEFT function

    something like

    $result = mysql_query("SELECT id, active, keyword, LEFT(adtitle,20) as newadtitle, impressions, clickthroughs from adverts WHERE advertiser='$advertiserid' order by $mysql_order desc LIMIT $offset, $limit " );


    then use newadtitle in your script
    Please don't PM me with questions.
    Use the forums, that is what they are here for.


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
  •