Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Jun 2005
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Is this possible?

    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?

    Example:

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

    and it shows 7?

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

  • #2
    Regular Coder
    Join Date
    Aug 2002
    Location
    Oregon, United States of America
    Posts
    882
    Thanks
    1
    Thanked 9 Times in 9 Posts
    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.
    If I'm postin here, I NEED YOUR HELP!!

  • #3
    New Coder
    Join Date
    Jun 2005
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks!

    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?


    Thanks

  • #4
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    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.

  • #5
    New Coder
    Join Date
    Jun 2005
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Ok thanks. I do not know very much java, but hopefully it is not very hard.

    Thanks


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •