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
Justice75Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Adobe Flash

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.