Results 1 to 3 of 3

Thread: auto incremental registration number not working php codeigniter framwork

  1. #1

    Thread Starter
    Registered User
    Join Date
    Feb 2020
    Posts
    3

    auto incremental registration number not working php codeigniter framwork

    I followed youtube tutorial but my codes are not working
    I want to auto increase registration number
    this is what I tried

    in model code
    PHP Code:
    public function auto() {
        
    $regNO "reg";
        
    $query 'select max(registerNO) as regNO_auto from student';
        
    $data $this->db->query($query)->row_array();
        
    $max_regNO $data['regNO_auto'];
        
    $max_regNO2 = (int)substr($max_regNO,7,3);
        
    $regNOcount $max_regNO2+1;
        
    $regNO_auto $regNO."-".sprintf('%07s'$regNOcount);
        return 
    $regNO_auto;

    in view

    PHP Code:
    <?php
      $regNO 
    $this->members_m->auto();
      echo 
    form_input([
       
    'name'=> 'registerNO',
       
    'class'=>'form-control',
       
    'value'=>set_value('registerNO'$regNO),
       
    'readonly'=>'true']);
     
    ?>
    this is what i want to get SPPS-0000001 and it should be auto increamental
    what am doing wrong
    is there a better way to get the same result than this

  2. #2
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    33,350

    Re: auto incremental registration number not working php codeigniter framwork

    1) What do you get? You've stated what you want, but not what you actually get.
    2) What is in your table? (data)
    3) Just as equally important, what does your table look like? (fields and so on)
    4) What about your insert? How are you inserting into the table?

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3

    Thread Starter
    Registered User
    Join Date
    Feb 2020
    Posts
    3

    Re: auto incremental registration number not working php codeigniter framwork

    Quote Originally Posted by techgnome View Post
    1) What do you get? You've stated what you want, but not what you actually get.
    2) What is in your table? (data)
    3) Just as equally important, what does your table look like? (fields and so on)
    4) What about your insert? How are you inserting into the table?

    -tg
    this line was an error
    after changing this line
    PHP Code:
    $regNO_auto $regNO."-".sprintf('%07s'$regNOcount); 
    to this

    PHP Code:
    $regNO_auto $regNO."-".sprintf('%03s'$regNOcount); 
    it is working but it gives SPPS-001. and it auto increases when new record is added.

    i really want to generate registration number in this squence 'SPPS-0000001'.
    any appropriate way of doing it

Posting Permissions

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



Click Here to Expand Forum to Full Width