1

I need a way through any language mysql, php, ect. to manually update a mysql database with a number of users based on a condition.

--My problem is I'm running a sports picks website and I need an easier way to update scores based on the picks users make--

--The way I do it now is through php and the user has to log in to trigger the function. i need a way to do it manually and effect all users--

3 Answers 3

1

You need crontab (in Linux) and php-cli module (command line)

With crontab you schedule a script call, the script that updates your scores.

Sign up to request clarification or add additional context in comments.

Comments

1

If you are really meaning manually, you could just make a normal PHP script, including the necessairy libraries, and calling that function without doing anything else.

If you are meaning automaticly (What makes more sense I think), you should be looking into cron. The script would be the same as above, however, instead of you executing it, your server can execute it at certain intervals.

More info on crons

Comments

0

MySQL's UPDATE can affect one or many rows depending on the conditions you set. So, if you want something that can be handled with a simple update or a complex one, you can either write that update (that affects all users) as a stored procedure and have the site automatically execute it either manually (so every user can trigger it but affect all users) or automatically (every time a user logins or logoffs or every 1000 clicks or whatever works best and does not runs the update millions of times every minute).

Or set up the site pages so only certain users (like only you, the Admin or a few more) can trigger the update manually, whenever they like.

In short, you don't need a cron job really (although you can use one if you are more familiar with those.)

1 Comment

Thanks! This is the best answer. I set it to update user's scores when an admin logs in. The problem I have now is a little hard to explain. I'm trying to figure out a short hand way to update each user's score based on the picks they make. But your solution definitely fixes the problem I listed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.