[eluser]davidbehler[/eluser]
So build one
To get a list of all characters from a - z use this
Code:
foreach(range('a', 'z') as $letter) {
echo $letter;
}
What you have to do is make each letter a link to your controller/function where this letter is then used to select all entries starting with the submitted character. Something like this might work:
Let's assume you want to list books with id and title column.
View (views/books_list.php)
Code:
<?php
foreach(range('a', 'z') as $letter) {
echo ' '.anchor('books/books_list/'.$letter, $letter);
}
?>
<b>Books:</b>
<table>
<tr>
<td>
ID
</td>
<td>
Title
</td>
</tr>
<?php
foreach($books as $book) {
?>
<tr>
<td>
<?php echo $book['id']; ?>
</td>
<td>
<?php echo $book['title']; ?>
</td>
</tr>
<?php
}
?>
?>
</table>
Controller (controllers/books.php):
Code:
<?php
class Books extends Controller {
function Books () {
parent:Controller();
}
function books_list($char = FALSE) {
$this->load->model('Books_model');
$data = array();
$data['books'] = $this->Books_model->get_list($char);
$this->load->view('books_list', $data);
}
}
Model (models/books_model.php):
Code:
<?php
class Books_model extends Model {
function Books_model() {
parent::Model();
}
function get_list($char = FALSE) {
$this->db->from('books');
if($char !== FALSE) {
$this->db->like('title', $char, 'after');
}
$this->db->order_by('title', 'asc');
$result = $this->db->get();
if($result->num_rows() > 0) {
return $result->result_array();
} else {
return array();
}
}
}
This is untested, but I guess you can see what I'm doing and use this to solve your problem.