[eluser]heitorcaldeira![/eluser]
Hey, thanks for reply.
Yes, i do this with 2 tables. The firts is 'posts'
CREATE TABLE `blog`.`posts` (
`id` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`name` VARCHAR( 100 ) NOT NULL ,
`body` TEXT NOT NULL ,
`date` VARCHAR( 50 ) NOT NULL
) ENGINE = MYISAM ;
And the second table is 'comments'
CREATE TABLE `blog`.`comments` (
`id` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`id_post` INT( 11 ) NOT NULL ,
`name` VARCHAR( 100 ) NOT NULL ,
`text` TEXT NOT NULL
) ENGINE = MYISAM ;
That is, the 2 tables were constructed normally, because before i did so:
Code:
$sql = mysql_query("SELECT * FROM posts");
while($row = mysql_fetch_object($sql))
{
echo "Post Name: " . $row->name;
/*
rest of code
...
*/
//comments
$sql2 = mysql_query("SELECT * FROM comments WHERE id_post = '" . $row->id . "')";
$num = mysql_num_rows($sql2);
echo "(" . $num . ") Comments in this post";
}
But i dont know how i do this with CI in MVC pattern.
Anyone can help me? :-)
Thanks !