• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 347
  • Last Modified:

ASP Datagrid LoadVars NEXT/BACK FUNCTIONS

Hi All,

I have a quick question.  Using the example from Member Negatyve (http://www.negatyve.com/EE/dg2004aspDB.zip) what if the table held 1,000 or more records.  How could you count al lof the records and load let's say 100 at a time into Flash and/or load into the databgrid?  Is this possible and does anyone have an example?  Any help would be greatly appreciated.

Thanks,

Justice
0
Justice75
Asked:
Justice75
  • 7
  • 6
1 Solution
 
vickerleungCommented:
Justice,

I think this should be the job of the database script side instead of Flash side

That means should be the job of the database script to select which 100 records and pass it to Flash

I can suggest the following code using PHP
I think if you know the logic, you can apply it to anywhere

<?
          $start_id = $_POST ["start_id"]; // This line is to get a variable passing from Flash
          $db->set_stmt ("SELECT * FROM DATA_TABLE LIMIT " . $start_id . ", 100"); // This line setup a SQL statement which retrieve the data
                                                                                                                         // the data are stored in that data_table and the place
                                                                                                                         // where the record start to get is the start_id(th) record

          ...... // And then some scripts to print the result back to Flash
?>

So for the Flash side
First of all you have the start_id variable to indicate the first record id appears in the datagrid
And then user loadVars post method to call the database script

e.g.

data_vars = new LoadVars;
data_vars.sendAndLoad ("database_script.php",this,"POST");

And then you may have a previous and next button which
1. Plus 100 or Minus 100 to the start_id
2. Rerun the loadvars section

Hope you got my meaning Justice~!! :)
Vicker
0
 
Justice75Author Commented:
Hi Vicker!

I am sorry but I did not understand the PHP.  I use ASP.  I also did not understand what you were saying with the Flash.  Can you help me a bit more?

Jsutice
0
 
vickerleungCommented:
Justice,

Ok I try my best here

ASP still use SQL statement right??

say for an example you have 1000 records in the DATA_TABLE

The following will gives you all the records, right?
SELECT * FROM DATA_TABLE

You wanna limit it to 100 records each time only, so in MySQL will be something like this'
This will gives you the 1st to 100th records
SELECT * FROM DATA_TABLE LIMIT 100

And this gives you the 3rd to 102nd records
SELECT * FROM DATA_TABLE LIMIT 3, 100 // Method A

Do ASP have something like this??
If NO! Then simply get all the records and store them into an array

e.g. data_array [] // which stores all 1000 records inside - Method B

If you are using Method A, that means you can change the value 3 to any number so that to get which 100 records you wanna have

And for method B, you can use the following to retrieve those 100 records you wanna have

starting_position = 3;
for (temp = 0; temp < 100; temp++)
{
  data_array_b [temp] = data_array [starting_position];
  starting_position++;
}

This way you can get the 3rd to 102nd record in the database

Hope till this point you got my meaning
Vicker
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
vickerleungCommented:
Ok, continue in the Flash part.

Actually you wanna tell the ASP which 100 records you wanna get,
so you will have a variable first to store that value

_root.starting_position = 99; e.g. the 99th record

And you pass this value to ASP using loadVars

ASP will catch this variable and then put into either Method A or Method B I have mentioned

Method A
SELECT * FROM DATA_TABLE LIMIT 99, 100

Method B
starting_position = 99;
for (temp = 0; temp < 100; temp++)
{
  data_array_b [temp] = data_array [starting_position];
  starting_position++;
}

To result the ASP gives you the 99th to 198th records


So how to control that variable starting_position
You can simply do so by two buttons (next and previous)

next_button.onRelease ()
{
     _root.starting_position = _root.starting_position + 100;
}

for previous it is - 100

So you can get whatever records you wanna have

I am sorry that I never tried ASP before~
Vicker
0
 
Justice75Author Commented:
Hi Vickerlung,
Thanks again for all of your help.

+++++++++++++_root.starting_position = 99; e.g. the 99th record+++++++++++++++++
And you pass this value to ASP using loadVars


Do I add this line to the _root timeline on frame one or do I need to make this is a textbox to hide?  Thanks,

Justice
0
 
vickerleungCommented:
A variable in root frame is  good enough~ :)

Vicker
0
 
Justice75Author Commented:
Vicker,

Can I just set in frame 1 as such :

_root.starting_position = 99;

?
Justice
0
 
vickerleungCommented:
Justice

Sure, that's okay

But I am thinking is that set to 1 is better?? :p

Vicker
0
 
Justice75Author Commented:
"But I am thinking is that set to 1 is better?? :p"

Vicker,
I am sorry, I dontknow what you mean when you say "set to 1 is better"?  Please let me know so that I dont get messed up later.

Justice
0
 
vickerleungCommented:
Justice

Because probably you will show the first 100 records starting from the record #1 ~~!!! XD

Vicker
0
 
Justice75Author Commented:
Thanks Vicker,
I take it and the code will update each 100 records?

Justice
0
 
vickerleungCommented:
Justice,

Can't get your meaning, sorry
Details please

Vicker
0
 
Justice75Author Commented:
Hi Vicker,

"_root.starting_position = 99;"
starting off should be:  _root.starting_position = 1;
then I said that the variable _root.starting_position = 101;
next it will be  _root.starting_position = 201;

and so on and so on.


Justice

0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 7
  • 6
Tackle projects and never again get stuck behind a technical roadblock.
Join Now