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.

leading zeroes increment number

Discussion in 'PHP' started by <?erick?>, May 30, 2008.

  1. #1
    hello guys im new php developer ryt now i have a have project my project is online ticketing system.. the one of my problem is incrematation and inserting number to mysql..for example i want to store number to mysql in this format 00000001 to 10000000 and if the year is change the number is go back to 00000001 and also if the number reach the max. is also go back to 00000001.
    please help me.. many thanks to all want to help me:):D
    <?erick?>, May 30, 2008 IP
  2. Altari

    Altari Peon

    Likes Received:
    Best Answers:
    Trophy Points:
    Your want str_pad

    $i = str_pad($i, 8, "0", STR_PAD_LEFT);
    This will take $i (your number) and turn it into an 8 character string filled with leading zeros.

    As far as the other part, it will just depend on the logic you want to use. Usually comparing the date of the two (in Unix time) is best for the year-to-year comparison.
    Altari, May 30, 2008 IP
  3. allaboutgeo

    allaboutgeo Peon

    Likes Received:
    Best Answers:
    Trophy Points:
    allaboutgeo, May 30, 2008 IP