How do I manage page with Array?

0 favourites
  • 6 posts
From the Asset Store
Template for making an interactive book or a simple story book
  • Hi there, I guess there is something I misunderstand with array.

    I can load datas with Ajax so that's great. It display now the first 10 entries but I don't know how to display the next 10 ones. I just want to navigate throw all entries.

    Do I have to reload the array each time?

    Tagged:

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • So this is my actual Event Sheet.

    I can load data, I even can move to the next 9 ones but I can't go back on the previous one.

    I'm really going mad on this… a solution anyone?

  • A quick answer to you is, do you set the width of the array to the entries you want to load?

  • Yes, I did put it on 50 just to test it. I have around 40 elements for now.

    But I realize that I was wrong about using array. My first idea was to load the entire datas from mysql in the array and then manage to show them part by part (on load display the firs 29 elements then show the next 29 ones and so on)

    But that's a problem if I load like 1000 elements. It will take hours to get all the elements into my array.

    So the idea is to prepare pages on the requested php. So I make this:

    $count = 9; $page = 0; if(isset($_GET['page'])) { $page = $count * intval(strip_tags(mysqli_real_escape_string($con, $_GET['page']))); }

    With this code I can load the first 9 row from mysql table as page 0.

    Now the idea is to use Ajax to change $page in the php so it can load the 9 next entries.

    And this is where I don't know how to do it.

    If I create a new request, it should looks like

    Ajax: send $page=+1 to URL MY_DOMAIN & "getdatas.php?page="page"

    Probably a confusion here…

  • I can load all my data but as I only put 29 Text object (3X3 for rank, user and score)

    This is what I got:

    I know that the rest of my data is already loaded with but how am I supposed to display it on the same Text object? like switching to the next 29 elements?

    Any idea someone?

  • I get the final answer.

    First change the php code:

    $count = 9; $page = 0; if(isset($_GET['page'])) { $page = $count * intval($_GET['page']); // $page = $count * intval(strip_tags(mysqli_real_escape_string($con, $_GET['page']))); }

    Then get the Ajax request like:

    DOMAIN_SCORES & "getscores.php?page="& CurrentPage

    Of course the CurrentPage should be a variable.

    Now you can load a lot of data without preload everything from your table!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)