[eluser]Unknown[/eluser]
Good afternoon everyone
Sorry for English.
I had no problems creating paging using data from a single table.
It happens that I have the following situation: I have two tables:
table1
`id` int(10) NOT NULL AUTO_INCREMENT,
`nome` varchar(40) NOT NULL,
`descricao` text NOT NULL,
table2
`id` int(10) NOT NULL AUTO_INCREMENT,
`titulo` varchar(200) NOT NULL,
`categoria` int(10) NOT NULL,
`resumo` text NOT NULL,
`descricao` text NOT NULL,
`foto` varchar(45) NOT NULL,
Here is the code to display the contents of a given table2
<?php
class Conteudo extends Controller {
function __construct()
{
parent::Controller();
$this->load->library('pagination');
}
function item($id)
{
$query = $this->db->get('table1');
$dados['table1'] = $query->result();
$my_query = "SELECT
tabel2.*,
table1.name as name_item
FROM table2
JOIN table1
ON table2.item = table1.id
WHERE table2.item =".$id; //I believe it is there that I should complete the instructions for paging ...
// I decided to make this change
$limite=2
$per_page=2
$my_query= $this->db->query ("SELECT table1.*, JOIN table1 ON table2.item = table1.id , $limite, $offset,$per_page");
// but returned the following error = You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'JOIN table1 ON table2.item = table1.id , 2, 1,2' at line 1
SELECT conteudo.*, JOIN categorias ON conteudo.categoria = categorias.id , 2, 1,2
$query = $this->db->query($my_query);
$dados['table2_table1'] = $query->result(); // this result needs to be passed with instructions pagination ...
$this->load->view('script2',$dados);
}
Here is the code script2
<?php
foreach ($table2_table1 as $item):
echo img("img/".$item->foto);
echo "<p>" .$item->resumo . "</p>";
echo "<a >id ."'>more...</a>";
echo "</span>";
endforeach;
echo "</div>";
?>
can someone give me a suggestion
Thanks