Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. Linux, Apache, MySQL, PHP
  4. how to use temporary values

how to use temporary values

Scheduled Pinned Locked Moved Linux, Apache, MySQL, PHP
tutorialdatabasemysqlregexannouncement
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kennyhibs
    wrote on last edited by
    #1

    Hi i have a mysql database which i use to update a soccer league table when i enter in results from a form, works fine, however i would like to be able to enter latest scores and update table based on latest scores entered but i cant work out how to do this as at the moment when i enter an update in the score for a match it will treat it as a new match and allocate points etc all over again Example teama 1 teamb 0 would give the following teama goals for 1, teamb goals for 0, goaldifference = teama goals for - teamb goals for which in thiscase would be 1 if it changed to teama 3 teamb 0 would give the following teama goals for 3, teamb goals for 0, goaldifference = teama goals for - teamb goals for which in thiscase would be 3 but it adds the 3 from this update to the 1 from previous update giving 4. so i need a way to stop it treating each update as a new result and only update with new data - the previous data so in my example 3 goals - 1 goal from first update = 2 goals , i have other fields like points that need to be treated same way. hope someone can helpout with this and point me in right direction kenny

    T 1 Reply Last reply
    0
    • K kennyhibs

      Hi i have a mysql database which i use to update a soccer league table when i enter in results from a form, works fine, however i would like to be able to enter latest scores and update table based on latest scores entered but i cant work out how to do this as at the moment when i enter an update in the score for a match it will treat it as a new match and allocate points etc all over again Example teama 1 teamb 0 would give the following teama goals for 1, teamb goals for 0, goaldifference = teama goals for - teamb goals for which in thiscase would be 1 if it changed to teama 3 teamb 0 would give the following teama goals for 3, teamb goals for 0, goaldifference = teama goals for - teamb goals for which in thiscase would be 3 but it adds the 3 from this update to the 1 from previous update giving 4. so i need a way to stop it treating each update as a new result and only update with new data - the previous data so in my example 3 goals - 1 goal from first update = 2 goals , i have other fields like points that need to be treated same way. hope someone can helpout with this and point me in right direction kenny

      T Offline
      T Offline
      Tony Richards
      wrote on last edited by
      #2

      Okay, how are you storing the data in the table (which I'll call Results). I'm imagining something like this after the first result:

      RowId Team1Id Team2Id Team1Score Team2Score
      0 1 2 1 0

      It sounds like you are doing an INSERT when you submit the data, which will give you:

      RowId Team1Id Team2Id Team1Score Team2Score
      0 1 2 1 0
      1 1 2 3 0

      When you want to update the score, use an UPDATE command instead of a INSERT command. You'll need the row's Primary Key (RowId in my example), and you'll end up with this:

      RowId Team1Id Team2Id Team1Score Team2Score
      0 1 2 3 0

      As you want.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups