Question

I have a random mysql response. I need to display the response in smarty template. I want to add dots in one column, but don't know how to do it. Here is my code:

function homepage_profiles()
{

        $sql = "
        SELECT
            *
        FROM
            tbl_profile
        WHERE
            bz_pro_show = 'Y'
        ORDER BY
            RAND()  
    ";
    $res = $this->db->returnArrayOfObject($sql, $pgin = 'no', $odr='no');
    return $res;
 }


$res_pro = $this->homepage_profiles();

$this->assign_values('rand_pro',$res_pro);
Was it helpful?

Solution

You could either use Smarty with something like {$rand_pro|truncate:50:'...'} or MySql with something like SELECT CONCAT(LEFT(about_me, 50),"...") as about_me_trunc ...

OTHER TIPS

$var['column'] = substr($var['column'], 0, 50)." ... ";

you can change your sql from select * ... to select col_a + '.', col_b, col_c ... .

NB: + operator is mysql-specific; other database servers use || or you can use CONCAT() to ensure portability.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top