Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2010
    Posts
    136

    Unanswered: Add letter JO on the autoincrement data produce

    Hi..

    I have code for auto increment of JO Number, now it display:
    120504001
    by using this code:
    PHP Code:
    <?php
      $sql 
    "SELECT jo_number FROM job_order ORDER BY jo_date DESC LIMIT 1";
            
    $result mysql_query($sql$con);
            
            if (!
    $result) {
                echo 
    'failed'
                die();
            }
            
    $total mysql_num_rows($result);
            if (
    $total <= 0) {
                
    $currentSRNum 1;
                 
    $currentYear  = (int)(date('y'));
                
    $currentMonth = (int)(date('m'));
                
    $currentDay = (int)(date('d'));
               
                
    $currentSRYMD substr($row['jo_number'], 06);
                
    $currentYMD date("ymd");
                if (
    $currentYMD $currentSRYMD
                {  
                    
    $currentSRNum 1;
                } 
                else 
                {  
                    
    $currentSRNum += 1;
                }     
                 
            } 
            else {
    //------------------------------------------------------------------------------------------------------------------
                // Stock Number iteration.... 
                
    $row mysql_fetch_assoc($result);
                
                
    $currentSRNum = (int)(substr($row['jo_number'],0,3));
                
                
    $currentSRYear  = (int)(substr($row['jo_number'],2,2));
                
    $currentSRMonth = (int)(substr($row['jo_number'],0,2));
               
    $currentSRNum = (int)(substr($row['jo_number'],6,4));
                
    $currentYear  = (int)(date('y'));
                
    $currentMonth = (int)(date('m'));
                
    $currentDay = (int)(date('d'));
               
                
    $currentSRYMD substr($row['jo_number'], 06);
                
    $currentYMD date("ymd");
                if (
    $currentYMD $currentSRYMD
                {  
                    
    $currentSRNum 1;
                } 
                else 
                {  
                    
    $currentSRNum += 1;
                }                                           
            }
    //------------------------------------------------------------------------------------------------------------------         
            
    $yearMonth date('ymd');    
            
    $currentSR $currentYMD sprintf("%03d"$currentSRNum);
    ?>
    now I want it to be:
    JO120504001
    JO120504002
    JO120504003
    JO120504004
    JO120505001
    JO120504002
    JO120504003

    Any help is highly appreciated.


    Thank you so much

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    if it the prefix is always JO why bother storing it.

    if you must refer to it as JO then fake it
    always display or report as JOxxxxx
    always input as JOxxxxxx, but strip off the JO before interacting with the database

    its redundant data, unless you want to use another prefix, but my guess is JO satnds for Job Order or similar and therefore is a useless piece of information to store
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Dec 2010
    Posts
    136
    Quote Originally Posted by healdem View Post
    if it the prefix is always JO why bother storing it.

    if you must refer to it as JO then fake it
    always display or report as JOxxxxx
    always input as JOxxxxxx, but strip off the JO before interacting with the database

    its redundant data, unless you want to use another prefix, but my guess is JO satnds for Job Order or similar and therefore is a useless piece of information to store
    How can I do your suggestion?

    Yes JO refers to Job Order

    Thank you

  4. #4
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002

Posting Permissions

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