Page 1 of 1

PHP to MySQL update

Posted: Mon Jun 14, 2010 7:00 am
by bineye
Hi. I am making a code so that people updating a league table would have much less hassle doing this. I have already created a form where they can put in a fixture, but what I want to do is to obtain current database values and update those values by the input values. Also, updating the games played automatically as well (ex: TeamA wins v TeamB -> add 1 to both TeamA and TeamB)
Can anyone help me on this?
Thanks :)

Re: PHP to MySQL update

Posted: Mon Jun 14, 2010 1:28 pm
by internet-solution
Basically, you are asking someone to build you the PHP / MySQL backend of your application, which is a big ask!

I suggest you start looking at PHP / MySQL basics. w3school.com is a good starting point, then move on to php.net and dev.mysql.com/doc/

Re: PHP to MySQL update

Posted: Tue Jun 15, 2010 3:46 am
by bineye
I'm sorry but that's not what I was asking at all. I have a lot written, like the overall posting etc. All I was asking was if anyone could show me how to take a database value, add a number and repost in table. I used what I need it for as an example ONLY. If someone has done this before, maybe a teacher doing a class's test scores, for example, then maybe they could show me how. Like if someone came on and wrote "variable +1" in a code box, or whatever, I could work from that. I may not have worded my question well, but it's people like you that discourage new members to stay in the community, by jumping to conclusions such as this. Others will come on and read your reply and automatically think that what you said is the case. I asked for one line, and you assume I want an entire application built?? That's an absolute disgrace tbh.

Re: PHP to MySQL update

Posted: Tue Jun 15, 2010 4:05 am
by aravona
Bineye, unfortunately thats what most people want.

You need to pull the value you want with something like:

$value = 'select whatever from wherever where something = something';

That way you get just the single data bit you want, so 'select wins from table where teamname = teamA' but fitting it to how you're database is set up obviously.

http://php.net/manual/en/function.mysql-fetch-assoc.php Then you need to use something like mysql_fetch_assoc (you may need to read up on which of these is best to uses if you need to use one)

then you can simply take your variable name $wins = $wins + 1, or something like it. The just use 'update whatever from wherever where something = something'

I'm a little sleepy, quite rusty, and mostly trying not to confuse myself with what you're asking. >.> but I think thats along the lines of what you needed?

Re: PHP to MySQL update

Posted: Tue Jun 15, 2010 5:30 am
by internet-solution
biney - apologies if I have offended you. I can understand your situation better after your second post.

The things you are asking about falls under the fundamentals about how PHP interacts with MySQL:
bineye wrote:.... but what I want to do is to obtain current database values and update those values by the input values.
Any database driven applications need to do the above steps regularly. I feel it would be more helpful to you if you read on this further, instead of looking for code examples. This will help you in long run.

Aravona has given you excellent advice above. php.net is the authorative source of information on PHP, but it can be quite daunting at first visit. So I suggest you spend some time on w3schools.com learning about PHP's MySQL functions.