A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: PHP / MySQL / Flash Help

  1. #1
    http://www.p-s-p.tk/
    Join Date
    Mar 2008
    Location
    England
    Posts
    20

    PHP / MySQL / Flash Help

    Ok, so good with flash however only just learning the rest, basically im making a score board for my game, game works and i can submit a score to the SQL server and view the values in an external php file. I have 3 fields in MySQL, UsernameSQL, ScoreSQL, ScoreID. I want to use the ScoreID field to tell flash whose first, second and so on... Is there a way to replace and update the record when it's topped, have a script to set the ScoreID if it's beaten whatever level, however i end up with two scores at the top, which stops flash working. Is there a replace function in PHP to replace a record in MySQL.

    Please Help

    (Hope that makes sense lol)

  2. #2
    Registered User
    Join Date
    Feb 2001
    Posts
    13,039
    Hi,

    why not get rid of the scoreId altogether?
    You add a new entry from flash, and on the way to flash you can use sql ORDER and LIMIT to show the winners. If you use an auto-index or date column, you can implement "same score is win" or "same score is lose" just in the sql code

    Musicman

  3. #3
    http://www.p-s-p.tk/
    Join Date
    Mar 2008
    Location
    England
    Posts
    20
    That is what i was looking for to begin with but i couldn't find any good tutorials on how to order content in mysql / php, thanks for the information, any links to a beginners tutorial?

  4. #4
    Senior Member joshstrike's Avatar
    Join Date
    Jan 2001
    Location
    Alhama de Granada, España
    Posts
    1,136
    The syntax is basically,

    SELECT usernameSQL, scoreSQL
    FROM scores
    [ORDER BY scoreSQL [DESC , ASC]]
    [LIMIT 10];

    Brackets meaning those lines are optional. Default ordering is ascending. Limiting takes place after ordering, so you'll either get the top ten or bottom ten scores this way.

    For most applications, we would not use a string username field for this table. We'd make it an unsigned integer which matched a userID in a separate table for users, and join that table with the syntax:

    SELECT users.username, scores.score
    FROM scores
    INNER JOIN users ON users.userID=scores.userID
    ORDER BY scores.score DESC
    LIMIT 10;

    That way you could also get the average score per player like this:

    SELECT AVG(scores.score) AS avgscore, users.username
    FROM users
    LEFT OUTER JOIN scores ON scores.userID=users.userID
    GROUP BY users.userID
    ORDER BY avgscore DESC
    LIMIT 10;

Posting Permissions

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




Click Here to Expand Forum to Full Width

HTML5 Development Center