All pastes #286030 Raw Edit

Untitled

public text v1 · immutable
#286030 ·published 2006-12-20 07:51 UTC
rendered paste body
	function getAll($offset, $limit = 2) 
	{
		$this->db->select('article_title, article_body');
		$this->db->from('article');
		$this->db->where('article_published', 1);
		$this->db->orderby('article_published_date', 'desc');
		$this->db->limit($limit,$offset);
		
		$result_set = $this->db->get();
		$num_rows = $result_set->num_rows();
		
		if ($num_rows > 0) {
			$output = '';
			foreach ($result_set->result() as $row) {
				$output .= '<h3>' . $row->article_title . '</h3>';
				$output .= '<p>' . $row->article_body . '</p>';
				
			}

		$output .= '<div class="page_turner">';

		if (($limit + $offset) -1 > $num_rows) { 
			$prev = $limit-$offset; 
			$output .= '<a href="' . $prev . '/"><< Back</a>'; 
		}
		
		} else {
			$output = '<p>No articles found.</p>';
		}

		return $output;				
	}