1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

On page load increase variable by one code?

Discussion in 'PHP' started by cagintranet, Dec 9, 2005.

  1. #1
    I would like to know how to increase a mysql variable +1 each time a php page is loaded. I would then need to insert that number back into a mysql database so that the next time that it's link gets clicked, the variable would increase another +1.

    I think i would be able to code it to get it to insert back into the DB, but i dont know how to do a sort of onload(variable = variable+1) php script.

    Any help would be appreciated!
     
    cagintranet, Dec 9, 2005 IP
  2. rvarcher

    rvarcher Peon

    Messages:
    69
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #2
    The PHP page being called should have this line:

    
    @mysql_query("UPDATE table SET field_name = field_name + 1 WHERE my_unique_id = '$unique_id'");
    
    PHP:
     
    rvarcher, Dec 9, 2005 IP
    cagintranet likes this.
  3. cagintranet

    cagintranet Well-Known Member

    Messages:
    328
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    128
    #3
    Thanks that worked!
     
    cagintranet, Dec 9, 2005 IP