Jump to content

How to upload new data to a mySQL database?


RichieW13

Recommended Posts

I am still very much a beginner in writing php code and using mySQL databases.  In order to teach myself more, I'm building a project (in my mind so far) to teach myself some skills.

 

What I want to do is create a little site for my fantasy football league.  Basically, I want to upload the player scores each week so that I can use the data to write various reports (high point scorers, etc.)

 

So each week I'll want to upload to my database the points scored for each player (there will be 140 players to upload each week).  Each player will be in the database and have a unique number to identify them.

 

So what would be the best way to upload the data?  I guess I will write a PHP form to input the data manually, but how do I associate the unique ID for each player so that his data for each week get associated with his row in the PlayerID table?  Do I have to create a dropdown list of all players in my database, and then pick him?  That seems like a slow way to go.

Link to comment
Share on other sites

Hi,

If you store the data that you want to upload in another location, you can associate in that location the data for each player with his id, then you write a script that reads those data and makes the upload automaticaly.

But it depends how you store or where you have the data you want to upload.

Link to comment
Share on other sites

Ultimately, you would want to write a script that scrapes the data from the same source you are manually getting it now and 'automatically' enter it into your database table by simply running the script.

 

However, for a starting project, you would want to display the list of names (either all at once or broken up by some scheme to give a more manageable amount of data to enter at one time) with either an input field next to each name or a drop down select menu next to each name to enter/pick the score. You would typically use an array for the field name with the player's id as the index to the array so that the value you enter/select is associated with the id. See this link for how to use an array for the html field name - http://us2.php.net/manual/en/faq.html.php#faq.html.arrays

 

Once the data is submitted, you can use php's array functions (such as foreach) to iterate over the data to get the id (the key/index of the array) and the score that was entered/picked.

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.