View Full Version : Is this possible?

07-02-2005, 07:09 AM
I am wondering if this is possible:

Have a number in a mysql table, then show it on a webpage (I know this is possible). Then, when a user on the site reaches a certain page, the number in the mysql table gets 10 subtracted from it. Then, the other users on the site will now see this new number instead of the old one.

I want to make a site where everyone sees the same number until one person reaches a page, then the number gets 10 subtracted from it.

I think I know how to do this, but is there a php command to have a variable be a number, and then subtract from that number?


$number = 10;
$newnumber = 10-3;
echo newnumber;

and it shows 7?

I hope this is clear. THANK YOU IF YOU CAN HELP!

07-02-2005, 07:25 AM
THis is more mysql. But yes.

On page X, you would grab the number from the table, set it to a PHP variable, subtract 10 from it, then update the mysql table with that number.

For instructions on how to do this, this should be moved to mysql.

07-02-2005, 03:49 PM

I know how to pull something from mysql, then put it back in.

The problem is I do not know how I would add 7 to it using php.

Also, this number is going to be on all pages on my site, and I would like it to update as soon as it is changed. It is important for the users to see the number has changed. Is there something better I should use than php, or can php somehow do this?


07-02-2005, 04:20 PM
Do you mean without updating the users page?
You will need an alternate language to go with it then, Flash, java, etc would be good choice to use. Unfortunatly, php is a static language, so you cannot create new variables to send until the users page updates.

07-02-2005, 05:01 PM
Ok thanks. I do not know very much java, but hopefully it is not very hard.