Justice75
asked on
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
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
ASKER
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
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
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
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
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
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
ASKER
Hi Vickerlung,
Thanks again for all of your help.
+++++++++++++_root.startin g_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
Thanks again for all of your help.
+++++++++++++_root.startin
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Vicker,
Can I just set in frame 1 as such :
_root.starting_position = 99;
?
Justice
Can I just set in frame 1 as such :
_root.starting_position = 99;
?
Justice
Justice
Sure, that's okay
But I am thinking is that set to 1 is better?? :p
Vicker
Sure, that's okay
But I am thinking is that set to 1 is better?? :p
Vicker
ASKER
"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
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
Justice
Because probably you will show the first 100 records starting from the record #1 ~~!!! XD
Vicker
Because probably you will show the first 100 records starting from the record #1 ~~!!! XD
Vicker
ASKER
Thanks Vicker,
I take it and the code will update each 100 records?
Justice
I take it and the code will update each 100 records?
Justice
Justice,
Can't get your meaning, sorry
Details please
Vicker
Can't get your meaning, sorry
Details please
Vicker
ASKER
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
"_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
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",thi
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