$sql = 'SELECT id,title FROM ' . NEWS_TABLE . " ORDER BY date DESC LIMIT 5"; $result = $db->query($sql); $num = $db->numrows($result); $i = 0; $data = array(); while ($i < $num) { $id = $db->result($result, $i, 'id'); $title = strip_tags($db->result($result, $i, 'title')); if (strlen($title) > 9) { $title = substr($title, 0, 9) . '...'; } $data[$i] = array('id' => $id, 'title' => $title); $i++; } $template->assign('recent', $data);