|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
2344223 Smarty Rookie
Joined: 31 Oct 2004 Posts: 5
|
Posted: Thu Jan 13, 2005 11:39 am Post subject: SmartyPaginate 1.2 Question - Help please. |
|
|
Hi guys.
i really like the paginate addon. thats exactly what i was searching for.
But i cant get it work
I hope you guys can help me with it. I am using Paginate 1.2 addon.
Here my code:
Code: |
session_start();
require('Smarty.class.php');
require('SmartyPaginate.class.php');
$smarty =& new Smarty;
// required connect
SmartyPaginate::connect();
// set items per page
SmartyPaginate::setLimit(25);
function get_db_results() {
$query = "SELECT * FROM game WHERE cat='3' LIMIT ". SmartyPaginate::getCurrentIndex() . " ". SmartyPaginate::getLimit();
$results = mysql_query( $query );
$_data = mysql_fetch_array( $results );
// set total number of items
SmartyPaginate::setTotal(count($_data));
return $_data;
}
// assign your db results to the template
$smarty->assign('results', get_db_results());
// assign {$paginate} var
SmartyPaginate::assign($smarty);
// display results
$smarty->display('index.tpl');
|
There must be sth. missing at the get_db_results function. I always get "This is no valid mysql_result_resource" as error message.
Does anyone know what i do wrong?
Thanks for help- |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Thu Jan 13, 2005 3:28 pm Post subject: |
|
|
For one, you need a comma in your query: LIMIT X,Y
I'm not sure if that is the root of the error message though, something might be wrong with the database access. |
|
Back to top |
|
2344223 Smarty Rookie
Joined: 31 Oct 2004 Posts: 5
|
Posted: Thu Jan 13, 2005 4:57 pm Post subject: |
|
|
ok maybe thats the problem.
so how is the right syntax then for the query, like this?
$query = "SELECT * FROM game WHERE cat='3' LIMIT ". SmartyPaginate::getCurrentIndex() . ", ". SmartyPaginate::getLimit();
I have some understanding problems with the . - Operator. would be nice if you could give me the right syntax.
thx a lot for you help |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Thu Jan 13, 2005 5:02 pm Post subject: |
|
|
That looks right. You can echo your $query value and see exactly what it is producing. |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|