Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    Feb 2005
    Posts
    663
    Thanks
    5
    Thanked 14 Times in 14 Posts

    Reset Fields back to 0?

    I've been running through some test where I have fields for a Win, Loss, and Tie. in a table.

    Now that testing is almost complete. Is there a way to reset all rows back to a 0 value?

  • #2
    Regular Coder
    Join Date
    Aug 2006
    Location
    UK, London, Dartford
    Posts
    221
    Thanks
    3
    Thanked 14 Times in 14 Posts
    In PHP My Admin, click Empty, and it'll reset the Table.

  • #3
    Super Moderator guelphdad's Avatar
    Join Date
    Mar 2006
    Location
    St. Catharines, Ontario Canada
    Posts
    2,631
    Thanks
    4
    Thanked 147 Times in 138 Posts
    well you can use one of two things.

    if you want to remove the rows entirely then use TRUNCATE, it will still keep your table intact but remove all data.

    that might not be what you want, even though it is fastest. if you have other data in those rows then you need to do an UPDATE on your table

    Code:
    UPDATE 
    yourtablename
    SET 
    wins = 0,
    losses = 0,
    ties = 0
    and that will reset all those values.

    Better still, in my opinion, if you are storing the results of football, hockey etc. etc., you are most likely already storing the score, either in this table or another one. Therefore you should not be storing wins, losses and ties at all, since these can be calculated by checking the game scores.

  • #4
    Regular Coder
    Join Date
    Feb 2005
    Posts
    663
    Thanks
    5
    Thanked 14 Times in 14 Posts
    Thanks. I didn't realize it was actually that simple.

    But no, I'm not storing the game scores. Every new game results in about 3 new tables being created. So they all get deleted when there completed to help keep things manageable.

    Thanks again though. I'm still a rooking at php and mysql, and didn't realize that it was simple of a query.

  • #5
    Super Moderator guelphdad's Avatar
    Join Date
    Mar 2006
    Location
    St. Catharines, Ontario Canada
    Posts
    2,631
    Thanks
    4
    Thanked 147 Times in 138 Posts
    You shouldn't be creating new tables every time you are introducing game scores. you should have a permanent table that would indicate

    1) gameid
    2) home team
    3) home score
    4) away team
    5) away score

    and you would add a new row for each game.

    perhaps you could show us what you are saving and why you find it necessary to create new tables each time you introduce new data.

    either I or someone else can help you improve what you are doing. as you say you are relatively new.


  •  

    Posting Permissions

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