469,658 Members | 1,835 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,658 developers. It's quick & easy.

Include this into my code..

133 100+

I currently use this for extracting data from my DB.

$new = new database;
$new->selects("SELECT * FROM table");
$result = $new->getRes();
$countrows = $new->countrows();

$smarty->assign('result', $result);
$smarty->assign('countrows', $countrows);

I have come across this though to extract data but includes pagnation also.

$dataCollection = array();
$getData = mysql_query("SELECT * FROM table");
$countrows = mysql_num_rows($getData);

while ($r=mysql_fetch_array($getData)) {
$tmp = array(
'field1' => $r['field1'],
'field2'=> $r['field2'],
'field3'=> $r['field3'],
'field4'=> $r['field4'],
'field5'=> $r['field5']

array_push($dataCollection, $tmp);


// Assign the results to an array
$pagination = new pagination();
$dataPages = $pagination->generate($dataCollection, 6);
$smarty->assign('listing', $dataPages);
$smarty->assign('pagination', $pagination->links());
$smarty->assign('countrows', $countrows);

My question is there any way to include the pagnation section into the first example as i don't like having to list all my fields.

Jul 17 '08 #1
2 1024
What is "pagnation" are you referring to pagination?
Anyway, there's no point in lines 6-12, you could have easily used array_push($dataCollection, $r) in stead of lines 6-14.
Jul 17 '08 #2
133 100+
Not exactly what i wanted but works just the same, cheers :)
Jul 17 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

By using this site, you agree to our Privacy Policy and Terms of Use.