Re: [SMARTY] page result with mysql -- with plug-in function.return_paged_results.php

From: Date: Sun, 23 Nov 2003 17:56:15 +0000
Subject: Re: [SMARTY] page result with mysql -- with plug-in function.return_paged_results.php
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-10592@lists.php.net to get a copy of this message
No i didn't ! but i will, thaks, Paolo. There is another plug-in (function.pager.php), it is giving me a lot of work too !(i am new to all this...). It seems to be more atractive because there is images on the page navegation links. This one did not work at all ! I know that i am doing something wrong, but for the ones like me, who are learning smarty now... the example inside the function file is so poor. The only example is: {pager rowcount=$LISTDATA.rowcount limit=$LISTDATA.limit txt_first=$L_MORE class_num="fl" class_numon="fl" class_text="fl"} I first got my sql result to a array, look: function mysql2array($result) { $retorno = array(); while ($dados = mysql_fetch_assoc($result)) { array_push($retorno, $dados); } return $retorno; } $result2 = mysql_query($query); $mysql_array = mysql2array($result2); $smarty->assign('LISTDATA',$mysql_array ); $smarty->assign('limit',"2" ); but i could not find a way to retrieve the rows from it! I mean, i could see that everythink was just fine with my query, and results array with print_r($mysql_array) function. can someone tell me, please, what i am doing wrong? regards, Ivan ----- Original Message ----- From: "Paolo Nesti Poggi" <pnp@italyflash.com> To: "Paolo Nesti Poggi" <pnp@italyflash.com>; "Ivan R. Cardoso" <ivan21@bol.com.br>; <smarty-general@lists.php.net> Sent: Sunday, November 23, 2003 1:35 PM Subject: SV: [SMARTY] page result with mysql -- with plug-in function.return_paged_results.php > Well it was not so clear, what I meant is that in your php you should have: > > > $connection = mysql_connect("$hostname", "$username", > > "$password"); > > $db = mysql_select_db("$database", $connection); > > $query = "select * from $table"; > > $smarty->assign('db',$connection); <--$connection instead of $db > > $smarty->assign('query',$query ); > > Paolo > > > -----Oprindelig meddelelse----- > > Fra: Paolo Nesti Poggi [mailto:pnp@italyflash.com] > > Sendt: 23. november 2003 15:02 > > > > > > I don't use smartypages however it seems to me that what you call $connect > > is what you in fact should put as the $db parameter in smatypages, that is > > the link identifier. > > > > This means that within your setup > > $count_result = mysql_query($count_query,$db); > > should instead be > > $count_result = mysql_query($count_query,$connect); > > > > Have you tried that? > > > > Greets > > Paolo > > > > > -----Oprindelig meddelelse----- > > > Fra: Ivan R. Cardoso [mailto:ivan21@bol.com.br] > > > Sendt: 23. november 2003 13:09 > > > > > > > > After some time.... i finaly found a way to make the > > > return_paged_results > > > (http://sourceforge.net/projects/smartypages/) plug-in to work. > > > > > > look; > > > ------------------------------------------------------------ > > > > > > (*.tpl) > > > > > > {return_paged_results db=$db query=$query shown=10} > > > > > > <table width=100%> > > > <tr > > > bgcolor=0000ff><td>cod</td><td>name</td><td>timestamp</td></tr> > > > {section name=mysec loop=$records} > > > {strip} > > > <tr class=celldados bgcolor="{cycle > > > values="#f0f0f0,#999999"}"> > > > <td width=10%>{$records[mysec].cod}</td> > > > <td>{$records[mysec].name}</td> > > > <td >{$records[mysec].timestamp}</td> > > > </tr> > > > {/strip} > > > {/section} > > > </table> > > > <p> {$page_string} > > > > > > --------------------------------------------------------- > > > > > > (*.php) > > > > > > $connection = mysql_connect("$hostname", "$username", > > > "$password"); > > > $db = mysql_select_db("$database", $connection); > > > $query = "select * from $table"; > > > $smarty->assign('db',$db ); > > > $smarty->assign('query',$query ); > > > > > > ----------------------------------------------------------- > > > > > > The only way that i found the plug-in to work, was to > > > change(function.return_paged_results.php, about line 74 and > > > 101...) from this: > > > > > > $count_result = mysql_query($count_query,$db); > > > > > > To this: > > > > > > $count_result = mysql_query($count_query); > > > > > > > > > hope it helps someone, cause i took a while to find out....! > > > > > > > > > Ivan R. Cardoso > > > > > > > > > > -- > > Smarty General Mailing List (http://smarty.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > >

« previous php.smarty.general (#10592) next »