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 p开发者_如何学JAVAicks 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--
You need crontab (in Linux) and php-cli module (command line)
With crontab you schedule a script call, the script that updates your scores.
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
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.)
精彩评论