SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast rekha_shp's Avatar
    Join Date
    Jan 2008
    Posts
    31
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Auto-increment alphanumeric numbers in php

    Hi all,

    I am developing invoice template.Can anyone suggest me how to auto-increment invoice number which may be alphanumeric number like "aaaa123","awrewr11"...........

  2. #2
    SitePoint Addict
    Join Date
    Apr 2009
    Posts
    248
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    $x "abc123";
    $x++;
    print 
    "$x\n"
    Should read abc124.

  3. #3
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    In a word. Don't.

    More often that not, it's only ever used when presenting the data. Use a regular incrementing key and build the reference as required.

    Code:
    SELECT CONCAT(
        id,
        '-',
        customer.code,
        '-',
        other.field
    ) AS reference FROM table;
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.


Bookmarks

Posting Permissions

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