开发者

PHP/MYSQL Update Specific Rows in Specific User Question

开发者 https://www.devze.com 2023-03-18 15:30 出处:网络
I\'m currently building up a prediction game website, in which people select specific answer for specific questions, they choose the answers from a <select> form on the website. Last time I did

I'm currently building up a prediction game website, in which people select specific answer for specific questions, they choose the answers from a <select> form on the website. Last time I did this, I got the people to choose their username and password from <select> fields too, and then when they put their answers in, it matched it to the username and updated the database using that.

For this updated version, I've got the users to log-in before hand, so I already have their开发者_C百科 name in a session available to me as it's used elsewhere on the page.

How do I go about updating their specific row in the database for a specific field. (Question probably doesn't make sense, so I'll give an example).

The user is signed in, their name in the database is Jerry and I've got them declared already.

session_register("name");

So there logged in now, they go to an event and from the select box which has the name 'World Cup' they choose their pick.

Now I want to update their specific row in the database and update the field 'World Cup' with their pick. How do I go about updating their row using what I've already got for their "name".

So I want to update the row "Jerry" and put their selection from the select box "World Cup" into the "World Cup" field. There will always be more than 1 field to update as well, probably around 10 fields per update which they can update whenever they want.

Does that make sense?


I think you want to use an UPDATE query.

UPDATE users
SET email_address='Jerry@yahoo.com', first_name='Jerry', last_name='Seinfeld'
WHERE username='JSeinfeld'
0

精彩评论

暂无评论...
验证码 换一张
取 消