I have a table with 3 fields: id (auto_increment), name (string), x.
in my x field i want it to be kind of like a auto_increment but with letters and numbers being used. For example, if id field is 1, x will be "aaaa". if id is 2 x will be "aaab" and so on. the idea is that with for digits i could have a 14 million unique ids. can someone please help me out?

6 Years
Discussion Span
Last Post by paullanesra

no thats not the problem. i can only have a 4 digits and i want to use they characters: abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.
Lets just say its to number an invoice. For the client looking up invoice no. 9,223,372,036,854,775,807 just isn'tt practical. Max for digits. Thanks fo your suggestion anyway.


In that case I would use something like this. The chances of getting two matching are however many records in 14 million combinations. If you're worried about duplicates though, you could always run a quick query to verify the record number doesn't exist already.

function createRandomInvoicce() { 

    $chars = "abcdefghijkmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ023456789"; 
    $i = 0; 
    $pass = '' ; 

    while ($i <= 3) { 
        $num = rand() % 33; 
        $tmp = substr($chars, $num, 1); 
        $invoice= $invoice. $tmp; 

    return $invoice; 


any body? something like client asking auto increment alphanumeric no

example ( ab100,ac100) somthing like this manner )?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.