Reputation: 667
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);
Upvotes: 1
Views: 943
Reputation: 9402
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
...
Upvotes: 4
Reputation: 14964
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.
Upvotes: 0