Jump to content

Arrays and mySQL


padams

Recommended Posts

I have only rudimentary PHP skills so have been struggling a bit to solve this problem. I am trying to build a dynamic website for a sports club, that allows users to enter new matches with details such as who played and who scored, and have this automatically update players statistics.

 

I have created a page where users can create a new match. On this page is a multiple-select List (named matchTeam) set up for users to select all of the players who played in the game. They click Submit and this sends all the data to a confirmation page. On this page I want a list of those players selected, along with how many games they have played. I have set up the List so that the value of the selected item(s) is playedID (a numeric primary key). This posts an array of a bunch of numbers to the confirmation page. I want to take this array and go to my mySQL database and go to the table called players, then create a recordset containing their names (in two fields, playerFirstName and playerLastName and the number of games they have played (playerGames). I will then echo this onto the confirmation page.

 

Finally, I'd also like to have textfields appear next to the names and games information, so that I can enter the number of tries/touchdowns they have scored. When the user clicks the Confirm button, it should automatically add 1 to the playerGames value for each player, and add the number in the tries/touchdowns field to the playerTries value for those players.

 

The problem I can't get my head around is that the matchTeam array that is posted to the confirmation page has multiple values in it, and I only know how to create a recordset based on one piece of information. How do I loop through the array and return the recordset with all the info I need?

 

Sorry about the lengthy explanation, but it seems like a complex problem (to me anyway!).

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.