473,394 Members | 1,700 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Include this into my code..

133 100+
Hi,

I currently use this for extracting data from my DB.

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

$smarty->assign('result', $result);
$smarty->assign('countrows', $countrows);
[/PHP]

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

[PHP]
$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);
[/PHP]


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.

Cheers,
Adam
Jul 17 '08 #1
2 1112
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
adamjblakey
133 100+
Not exactly what i wanted but works just the same, cheers :)
Jul 17 '08 #3

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

Similar topics

43
by: steve | last post by:
I am quite frustrated with php’s include, as I have spent a ton of time on it already... anyone can tell me why it was designed like this (or something I don’t get)? The path in include is...
2
by: puzzlecracker | last post by:
after reading some of the post I found out something rather radical to my previous understanding: that when you do #include<iostream> #include<string> #include<vector> etc compiler puts...
5
by: David Mathog | last post by:
One thing that can make porting C code from one platform to another miserable is #include. In particular, the need to either place the path to an included file within the #include statement or to...
2
by: key9 | last post by:
Hi all look at the organize tree main.c ------ #include lib_adapter.c main() { foo();
4
by: Jon Slaughter | last post by:
I'm using eval to excute some mixed php and html code but I cannot debug it. I am essentially using filegetcontents to load up a php/html file and then inserting it into another php/html file and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.