Welcome, Guest. Please login or register.
Did you miss your activation email?
05/22/12, 07:23
Home Help Search Login Register
News: Parsley Flex framework review featuring quiz application, in our Flex frameworks series
Flex SDK 4.5 mobile roadmap: begin with your mobile development
Swiz Flex framework review featuring quiz application
New homepage we release our new Homepage, take a look ...

+  Flash-db
|-+  Server side Scripting and Database Support
| |-+  PHP, Perl, ASP, JSP, CFM (Moderators: Flash-db, Musicman, vesa kortelainen, Ronald Wernecke, Jorge Solis, nothingGrinder)
| | |-+  pagination
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] Print
Author Topic: pagination  (Read 1685 times)
brentc73
Server what's that
*
Posts: 16


View Profile WWW
« on: 10/30/09, 18:46 »

I need somekind of pagination to show 15 record at a time/per page... cannot figure it out. Any help would be appreciated.

This is my as
Code:
var xPos = 30;
var yPos = 100;
var spacing = 150;
var colMargin = 10;
var columns = 5;


this.ref["employeethumb"+i]._x = 50;
myData = new LoadVars();
myData.ref = this;
myData.onLoad = function(success) {
if (success) {
for (var i = 0; i<this.count; i++) {
attachMovie("employ","employeethumb"+i,i,{_x:xPos, _y:yPos});
rowNumber = Math.floor(i/columns);
this.ref["employeethumb"+i]._x = xPos+(i-(rowNumber*columns))*(spacing+colMargin);
this.ref["employeethumb"+i]._y = yPos+Math.floor(i/columns)*spacing;
this.ref["employeethumb"+i].ename.text = this["names"+i];
this.ref["employeethumb"+i].moreinfo.uri = this["id"+i];
this.ref["employeethumb"+i].eimages.loadMovie(this["image"+i]);
dataload.gotoAndPlay(2);
this.ref["employeethumb"+i].moreinfo.onRelease = function() {
_global.name2 = this.uri;
dataload.gotoAndPlay(1);
trace(_global.name2);
sendIt3();
};
}
}
};
myData.load("employee_link.php?random="+random(1000000));

This is my php

Code:
<?
//Database Connectivity Variables//
$host = "xx";
$dbuser = "xx";
$dbpass = "xx";
$dbname = "xx";
$table = "employee";
//Create a connection to the MySQL Database//
$connection = @mysql_connect($host,$dbuser,$dbpass) or die("Couldn't Connect.");
$db = @mysql_select_db($dbname, $connection) or die("Sorry, I could not select the requested Database ");


$sql = "SELECT * FROM $table where active ='Y' ORDER BY id";
$result = @mysql_query($sql, $connection) or die("Couldn't execute query.");
$count = 0;
while($row=mysql_fetch_array($result)){
    $target = $row['location']."".$row['image'];
echo "id$count=$row[id]&names$count=$row[name]&image$count=$target&";
$count++;
}
echo "count=$count";
?>

« Last Edit: 10/30/09, 18:53 by brentc73 » Logged
Ronald Wernecke
Administrator
Systems Administrator
*****
Posts: 6175


View Profile WWW Email
« Reply #1 on: 10/31/09, 01:57 »

Hi Brent,

you have to manage this at the server with php and mySQL and send a startnumber with the request.

You can get the total number of records with mysql_num_rows.
With the LIMIT command at the end of a query, you can limit the output.

So
Code:
SELECT * FROM $table where active ='Y' ORDER BY id LIMIT 0,15
delivers the first 15 records, while
Code:
SELECT * FROM $table where active ='Y' ORDER BY id LIMIT 15,15
delivers the next chunk.
Now it is yours again Wink
Logged

happy flashing
Cool
Ronald
brentc73
Server what's that
*
Posts: 16


View Profile WWW
« Reply #2 on: 11/04/09, 14:01 »

Hi Ronald,

That you for your response... I am close but not there yet.
I cannot figure out how to increment my var by more than one...

I changed my as to

Code:
var xPos = 30;
var yPos = 100;
var spacing = 150;
var colMargin = 10;
var columns = 5;


this.ref["news"+i]._x = 50;
var employee:Array = [];
myRData = new LoadVars();
myRData.ref = this;
myRData.onLoad = function(success) {
if (success) {
for (var i = 0; i<this.count; i++) {
attachMovie("employ","news"+i,i,{_x:xPos, _y:yPos});
root.emain.news.ename.text.scroll += 1;
rowNumber = Math.floor(i/columns);
this.ref["news"+i]._x = xPos+(i-(rowNumber*columns))*(spacing+colMargin);
this.ref["news"+i]._y = yPos+Math.floor(i/columns)*spacing;
this.ref["news"+i].ename.text = this["names"+i];
this.ref["news"+i].moreinfo.uri = this["id"+i];
this.ref["news"+i].eimages.loadMovie(this["image"+i]);
dataload.gotoAndPlay(2);
this.ref["news"+i].moreinfo.onRelease = function() {
_global.name2 = this.uri;
dataload.gotoAndPlay(1);
sendIt3();
};
}
}
};

var offsetsnum = 0;
function sendIt1() {
var myData = new LoadVars();
myData.offsets = offsetsnum;
myData.sendAndLoad("employee_link.2.php?random="+random(1000000),myRData,"POST");
}
sendIt1();

My "next button" increments the var I am sending to my php/mysql limits by 1 and I need it to be 5... I have a tried a bunch of things but I cannot get it to work, any idea?

Code:
on (release) {
offsetsnum++;
trace(offsetsnum);
sendIt1();
}
Logged
Ronald Wernecke
Administrator
Systems Administrator
*****
Posts: 6175


View Profile WWW Email
« Reply #3 on: 11/04/09, 15:02 »

root.emain.news.ename.text.scroll += 15; // or whatever number of records/page
Logged

happy flashing
Cool
Ronald
brentc73
Server what's that
*
Posts: 16


View Profile WWW
« Reply #4 on: 11/04/09, 15:11 »

Hi Ronald,

Yep I just go it by modifing my button to

Code:
on (release) {
offsetsnum += 5;
trace(offsetsnum);
sendIt1();
}

Thank you.
Logged
Pages: [1] Print 
« previous next »
Jump to:  


Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!