The forums have permanently moved to forum.kirupa.com. This forum will be kept around in read-only mode for archival purposes. To learn how to continue using your existing account on the new forums, check out this thread.


Results 1 to 8 of 8

Thread: Flash, PHP & mySQL - LIMIT problem

  1. #1
    5
    posts
    Registered User

    Flash, PHP & mySQL - LIMIT problem

    Hello.. I think this is my first post

    Okay, I'm using PHP to output data from mySQL as XML. Then using flash to display it. I'm using LIMIT in my call to the database, to show only 2 results at a time. There could be only 2 rows or there could be 999 rows, but I would only like to display 2 at a time. I'd think it reduces the like.. immediate download time? Right?

    Anyway.. I'd like to be able to have a button which, when pressed, would display the 2nd and 3rd row's data, and then the 3rd and 4th's and so on... I think I'd have to increase the starting variable ($x) and reload the php data.Is that right?..

    How do I do that? Change the $x in the php from the flash file.

    Or is there a better way? If I loaded up the whole table into the php file, I could easily use flash to navigate through the outputted xml, but.. that would increase the load time dramatically, wouldn't it?

    Is using xml the best way to do it? Would it be easier if I just parsed using php without converting it to xml?

    Thanks for taking the time to read, and sorry for all the questions

    -grez

  2. #2

  3. #3
    5
    posts
    Registered User
    Quote Originally Posted by bwh2 View Post
    http://www.plus2net.com/sql_tutorial/sql_limit.php

    so you're just changing your start row.
    Yeh.. couldn't have said it better myself. So how do I do that from flash?

  4. #4
    well, there's a trade off. basically:
    Code:
    steps for each query
    -----------------------------
    1. flash sends vars to php
    2. php sends query to sql
    3. sql queries
    4. sql returns records to php 
    5. php outputs records to xml
    6. flash reads xml
    if you use the LIMIT [rowend],[rowstart] method, you are speeding up 3, 4, 5, and 6. but it also means you need to run through that process many times.

    if you use a higher limit, let's say you return 100 rows, you are slowing down 3 slightly, 4 slightly, 5 a little more, 6 a little more. but you run through the process fewer times.

    i'm not sure what would be fastest. i would probably opt for just running a larger query. maybe pull back 300 or so records.

    it's a cost/benefit analysis you have to do.

  5. #5
    5
    posts
    Registered User
    I see, so if I return 100 rows into the php and output them all to xml then the download time would be less- overall.

    But what I really want to know is, how would I make a button in flash which tells the php to load the next 100 rows after it's been through them all. I'm guessing I could change the childNodes[X] using a button in flash, make it add 1 each time and when it reaches 100, restart at 0. But how could I use actionscript to have the php change the query to sql? Is it possible, since the swf reads the php as xml?

    Thanks for your help

  6. #6
    Its better to put it all in an array.
    then just handle the array from flash.

  7. #7
    602
    posts
    Backend Specialist
    ^Agreed, given there aren't too many values being returned. If this list gets bigger by activity (viewing logs, user list, etc...) I suggest using LIMIT with MySQL to get results as needed. Or if you know the list won't grow over time and it's not too big, just return the whole thing and have flash handle any paging necessary.

  8. #8
    5
    posts
    Registered User
    Quote Originally Posted by skOOb View Post
    ^Agreed, given there aren't too many values being returned. If this list gets bigger by activity (viewing logs, user list, etc...) I suggest using LIMIT with MySQL to get results as needed. Or if you know the list won't grow over time and it's not too big, just return the whole thing and have flash handle any paging necessary.
    Yeah, that's the thing. Over time it will get bigger. I was just wondering about download times. If I'm calling about 3000 rows from a database, all with 10 or so columns, it may take a while. If it's my only option, then I suppose I'll just have to make a little animation to keep people busy. Thanks for your help guys

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012