Error message not displaying in CodeIgniter - php

I want to edit some data after a POST in CodeIgniter.
The problem is when I make an edit I want to show a message that tells me the edit is done. I tried to do the following, but no message is displayed. Why?
Controller
function edit($id = 0) {
$this->load->model('Event_Model');
if ($id > 0) {
$this->data['eventinfo'] = $this->Event_Model->getInfo($id);
}
$this->data['pagetitle'] = "Edit";
$this->data['formID'] = $this->uri->segment(2)."-".$this->uri->segment(3);
$this->template->build('admin/events/add',$this->data);
}
function do_edit() {
$this->load->model('Event_Model');
$id = $this->input->post('hID');
$data = array(
'ev_text' => $this->input->post('ev_text'),
'ev_pic' => $this->input->post('ev_pic'),
);
$this->Event_Model->update($id, $data);
$this->data['success'] = "Done";
$this->data['errors'] = $this->errors;
$this->template->build('admin/events/add',$this->data);
}
Model
function update($id, $data) {
$this->db->where('ev_id', $id);
$this->db->update('events', $data);
}
View (where I want the message)
<?php
if (isset($success)) { ?>
<div class="alert alert-success normal-alert" style="display: block;">
<p><span class="ico-text ico-alert-success" ></span><?= $success; ?></p>
</div>
<?php
}
if (isset($errors)) { ?>
<div class="alert alert-error normal-alert" style="display: block;">
<div>
<span class="ico-text ico-alert-error"></span>
<?php if (count($errors) > 0) { ?>
<ul>
<?php
foreach ($errors as $error) {
echo "<li>$error</li>";
}
?>
</ul>
<?php } ?>
<div class="clear"></div>
</div>
</div>
<?php } ?>
and the second error, update data with picture not work, its get me error in dubg that call me the $_FILES['choose-file']['name'] not define

Try This:
Controller
function do_edit() {
$this->load->model('Event_Model');
$id = $this->input->post('hID');
$data = array(
'ev_text' => $this->input->post('ev_text'),
'ev_pic' => $this->input->post('ev_pic'),
);
$result = $this->Event_Model->update($id, $data);
if($result) {
$this->data['success'] = "Done";
$this->template->build('admin/events/add',$this->data);
}
$this->data['errors'] = $this->errors;
$this->template->build('admin/events/add',$this->data);
}
Model:
function update($id, $data) {
$this->db->where('ev_id', $id);
$this->db->update('events', $data);
return $this->db->affected_rows();
}

Related

Retrieve data from two tables in PHP Codeigniter

I want to retrive count of datas from one table and some datas from another table , also i want to know how to display these in a single foreach loop.
Model
public function counter(){
$this->db->where('package_id', $id);
$this->db->from('gt_package');
$cnt = $this->db->count_all_results();
}
Controller
public function package_category_listing()
{
$data['records'] = $this->gt_package_model->counter();
$query = $this->db->get("gt_package_category");
$data['records'] = $query->result();
$this->load->view('admin/package/package_category_listing',$data );
}
View part :
<?php foreach ($records as $r) { ?>
<div class="col-sm-6 col-md-3 col-xs-12">
<div class="bg-purple">
<h4 class="text-white">
<?php echo $r->category_name; ?>
</h4>
<span>200</span> Packages
<br>
<a style="margin-top: 10px;" href="<?php echo site_url() . "/gt_package/listing/" . $r->category_id ?>" class="btn btn-default">View Packages</a>
</div>
</div>
<?php } ?>
As per your question to pass the data model to controller code bellow
Model:
public function counter()
{
$this->db->where('package_id', $id);
$this->db->from('gt_package');
$query = $this->db->get('gt_package');
$cnt = $query->num_rows();
return $cnt;
}
Controller:
public function package_category_listing()
{
$data['records'] = $this->gt_package_model->counter();
$query = $this->db->get("gt_package_category");
$data['records'] = $query->result();
$this->load->view('admin/package/package_category_listing',$data );
if($res){
$data['result'] = $res;
$this->load->view('manage_accounts_view', $data);
} else {
echo "Fail";
}
print_r($data['result']);
}

Displaying the blog pagetitle as a url in codeigniter php

I am having a blog page where the blogs are inserted from admin panel and blog title will be inserted into new column as separated by " - " if there are spaces between the page titles.For example if the page title is " welcome to something " then in the database it is will be inserted into two columns. In once column it will be inserted as same and in other column it will be inserted as welcome-to-something.
when clicking on readmore button i need to display in url as (www.example.com/blob/article/welcome-to-something) in this format i need to display the url.
Here is the code:
Controller:
public function index()
{
$this->load->model('blogs_model');
$data["records2"] = $this->blogs_model->get_all_blogs($config["per_page"], $page);
$data['mainpage'] = "blog";
$this->load->view('templates/template',$data);
}
public function article()
{
$this->load->model('blogs_model');
$data['records2']= $this->blogs_model->getblogsdata($this->uri->segment(3));
$data['mainpage']='blogs';
$this->load->view('templates/templatess',$data);
}
Model:
function get_all_blogs()
{
$this->db->select('B.*');
$this->db->from('blogs AS B');
$this->db->where(array('B.status'=>1));
$this->db->order_by("position", "asc");
$q = $this->db->get();
if($q->num_rows()>0)
{
return $q->result();
}
else
{
return false;
}
}
function getblogsdata($id)
{
$this->db->select('blogs.*');
$this->db->from('blogs');
$this->db->where(array('blogs.blog_id'=>$id));
$q=$this->db->get();
if($q->num_rows()>0)
{
return $q->result();
}
else
{
return false;
}
}
View:
<div class="col-md-9 blogs">
<?php if(isset($records2) && is_array($records2)):?>
<?php foreach ($records2 as $r):?>
<div class="blog1">
<img src="<?php echo base_url();?>admin/images/blogimages/thumbs/<?php echo $r->image_path;?>" class="testimonials1"/>
<h3 class="heading1"><?php echo $r->blog_title;?></h3>
<div class="blogtext1 read">
<?php echo $r->description;?>
</div>
<a href="<?php echo base_url()?>blog/article/<?php echo $r ->blog_id ;?>" class="read_more7" target="_blank" >Read More</a>
</div>
<?php endforeach ;endif;?>
<div class="pagination"><?php echo $links; ?></div>
</div>
blogs table
blog_id | blog_title | blogtitle
1 welcome to something welcome-to-something
Model:
function getblogsdata($id,$slug)
{
$this->db->select('blogs.*');
$this->db->from('blogs');
$this->db->where(array('blogs.blogtitle'=>$id));
$this->db->where(array('blogs.blogtitle' => $slug));
$this->db->order_by("ne_views", "asc");
$q=$this->db->get();
if($q->num_rows()>0)
{
return $q->result();
}
else
{
return false;
}
}
View:
<a href="<?php echo base_url()?>blog/article/<?php echo $r->blogtitle;?>" class="read_more7" target="_blank" >Read More</a>

my query in codeigniter cannot produce result

i've been debbuging it many times based on my knowledge, i am new to codeigniter, any solution idea would be much appreciated... ty
here's my code
MODEL:
function userdisplay_info($id){
$result = $this->db->query("SELECT uid FROM user WHERE userIdentificationNumber LIKE '$id'");
//if($result->num_rows() > 0){
$info_data = $result->result();
$row = $info_data[0];
$result->free_result();
}
CONTROLLER:
function r_book(){
$data = array();
$bid = $this->input->post('bid');
$u_id = $this->input->post('userinputid');
$data = array(
'book_reserved' => 1
);
if($this->module2->reserved_book($bid,$data))
{
$data['info'] = $this->module2->userdisplay_info($u_id);
$this->load->view('User/template/header');
$this->load->view('User/template/navigator');
$this->load->view('User/landingpage',$data);
$this->load->view('User/template/footer');
return true;
}else
{
$this->load->view('User/template/header');
$this->load->view('User/template/navigator');
$this->load->view('User/landingpagefail');
$this->load->view('User/template/footer');
return false;
}
}
VIEW:
<div class="col-md-3">
<div class="panel panel-default">
<div class="panel-body">
<?php if($info) : foreach($info as $u_info) : ?>
<ul class="list-unstyled">
<li>Last Name : <?php echo $u_info->uid; ?></li>
<li>First Name : <?php echo $u_info->userFirstname; ?></li></li>
<li>Middle Name : <?php echo $u_info->userMiddlename; ?></li></li>
<li>Course : <?php echo $u_info->userCourse; ?></li></li>
</ul>
<?php endforeach; ?>
<?php else :?>
<h4> No Record Found</h4>
<?php endif; ?>
</div>
</div>
</div>
Rewrite your model function as
function userdisplay_info($id){
$this->db->select('uid');
$this->db->like('userIdentificationNumber', $id);
$query = $this->db->get('user');
return $query->result_array();
}

error illegal string offset in codeigniter

i am getting error illegal sting offset in variable 'slug' and 'judul' in my view. can you tell me what the probelm.
controller
function index()
{
$slug = $this->uri->segment(2);
$this->data['halaman'] = $this->mhalaman->get_profil($slug);
if (empty($this->data['halaman'])) {
show_404();
}
$this->data['judul'] = $this->data['halaman']['judul'];
//var_dump($halaman_item['slug']);
$this->data['orang'] = $this->mlogin->dataPengguna($this->session->userdata('username'));
$this->data['contents'] = $this->load->view('page', $this->data, true);
$this->load->view('template/wrapper/mahasiswa/wrapper_content',$this->data);
}
view
<div class="section ui dropdown link item">
<span class="count">Profil</span>
<div class="menu">
<?php foreach ($halaman as $dt) : ?>
<div class="item">
<?php echo $dt['judul'] ?> //line error
</div>
<?php endforeach; ?>
</div>
</div>
modal
function get_profil($slug = FALSE)
{
if ($slug === FALSE)
{
$query = $this->db->get($this->tbl_halaman);
return $query->result_array();
}
$query = $this->db->get_where($this->tbl_halaman, array('slug'=>$slug));
return $query->row_array();
}
please help me what to do. thank you
It should be echo $dt instead of echo $dt['slug']

Automatically fill a field incremented by the previous value in Codeigniter - PHP Point of Sale 11.3

I'm making some modifications in PHP Point of Sale 11.3. Presently called as Open Source Point of Sale which is build using Codeigniter.
While adding a new item into inventory, there is a text field which I wanted to be filled automatically incremented by one than the value of the previous item.
The view code:
<?php
echo form_open('items/save/'.$item_info->item_id,array('id'=>'item_form'));
?>
<fieldset id="item_basic_info">
<legend><?php echo $this->lang->line("items_basic_information"); ?></legend>
<div class="field_row clearfix">
<?php echo form_label($this->lang->line('items_item_number').':', 'name',array('class'=>'wide')); ?>
<div class='form_field'>
<?php echo form_input(array(
'name'=>'item_number',
'id'=>'item_number',
'value'=>$item_info->item_number)
);
?>
</div>
</div>
<div class="field_row clearfix">
<?php echo form_label($this->lang->line('items_name').':', 'name',array('class'=>'required wide')); ?>
<div class='form_field'>
<?php echo form_input(array(
'name'=>'name',
'id'=>'name',
'value'=>$item_info->name)
);?>
</div>
</div>
<div class="field_row clearfix">
<?php echo form_label($this->lang->line('items_category').':', 'category',array('class'=>'required wide')); ?>
<div class='form_field'>
<?php echo form_input(array(
'name'=>'category',
'id'=>'category',
'value'=>$item_info->category)
);?>
</div>
</div>
<div class="field_row clearfix">
<?php echo form_label($this->lang->line('items_supplier').':', 'supplier',array('class'=>'required wide')); ?>
<div class='form_field'>
<?php echo form_dropdown('supplier_id', $suppliers, $selected_supplier);?>
</div>
</div>
<div class="field_row clearfix">
<?php echo form_label($this->lang->line('items_cost_price').':', 'cost_price',array('class'=>'required wide')); ?>
<div class='form_field'>
<?php echo form_input(array(
'name'=>'cost_price',
'size'=>'8',
'id'=>'cost_price',
'value'=>$item_info->cost_price)
);?>
</div>
</div>
<div class="field_row clearfix">
<?php echo form_label($this->lang->line('items_unit_price').':', 'unit_price',array('class'=>'required wide')); ?>
<div class='form_field'>
<?php echo form_input(array(
'name'=>'unit_price',
'size'=>'8',
'id'=>'unit_price',
'value'=>$item_info->unit_price)
);?>
</div>
</div>
<div class="field_row clearfix">
<?php echo form_label($this->lang->line('items_tax_1').':', 'tax_percent_1',array('class'=>'wide')); ?>
<div class='form_field'>
<?php echo form_input(array(
'name'=>'tax_names[]',
'id'=>'tax_name_1',
'size'=>'8',
// 'value'=> isset($item_tax_info[0]['name']) ? $item_tax_info[0]['name'] : $this->config->item('default_tax_1_name'))
'value'=> isset($item_tax_info[0]['name']) ? $item_tax_info[0]['name'] : $this->config->item('default_tax_1_name'))
);
?>
</div>
<div class='form_field'>
<?php echo form_input(array(
'name'=>'tax_percents[]',
'id'=>'tax_percent_name_1',
'size'=>'3',
'value'=> isset($item_tax_info[0]['percent']) ? $item_tax_info[0]['percent'] : $default_tax_1_rate)
);?>
%
</div>
</div>
<div class="field_row clearfix">
<?php echo form_label($this->lang->line('items_tax_2').':', 'tax_percent_2',array('class'=>'wide')); ?>
<div class='form_field'>
<?php echo form_input(array(
'name'=>'tax_names[]',
'id'=>'tax_name_2',
'size'=>'8',
'value'=> isset($item_tax_info[1]['name']) ? $item_tax_info[1]['name'] : $this->config->item('default_tax_2_name'))
);?>
</div>
<div class='form_field'>
<?php echo form_input(array(
'name'=>'tax_percents[]',
'id'=>'tax_percent_name_2',
'size'=>'3',
'value'=> isset($item_tax_info[1]['percent']) ? $item_tax_info[1]['percent'] : $default_tax_2_rate)
);?>
%
</div>
</div>
<div class="field_row clearfix">
<?php echo form_label($this->lang->line('items_quantity').':', 'quantity',array('class'=>'required wide')); ?>
<div class='form_field'>
<?php echo form_input(array(
'name'=>'quantity',
'id'=>'quantity',
'value'=>$item_info->quantity)
);?>
</div>
</div>
<div class="field_row clearfix">
<?php echo form_label($this->lang->line('items_reorder_level').':', 'reorder_level',array('class'=>'required wide')); ?>
<div class='form_field'>
<?php echo form_input(array(
'name'=>'reorder_level',
'id'=>'reorder_level',
'value'=>$item_info->reorder_level)
);?>
</div>
</div>
<div class="field_row clearfix">
<?php echo form_label($this->lang->line('items_location').':', 'location',array('class'=>'wide')); ?>
<div class='form_field'>
<?php echo form_input(array(
'name'=>'location',
'id'=>'location',
'value'=>$item_info->location)
);?>
</div>
</div>
<div class="field_row clearfix">
<?php echo form_label($this->lang->line('items_description').':', 'description',array('class'=>'wide')); ?>
<div class='form_field'>
<?php echo form_textarea(array(
'name'=>'description',
'id'=>'description',
'value'=>$item_info->description,
'rows'=>'5',
'cols'=>'17')
);?>
</div>
</div>
<div class="field_row clearfix">
<?php echo form_label($this->lang->line('items_allow_alt_desciption').':', 'allow_alt_description',array('class'=>'wide')); ?>
<div class='form_field'>
<?php echo form_checkbox(array(
'name'=>'allow_alt_description',
'id'=>'allow_alt_description',
'value'=>1,
'checked'=>($item_info->allow_alt_description)? 1 :0)
);?>
</div>
</div>
<div class="field_row clearfix">
<?php echo form_label($this->lang->line('items_is_serialized').':', 'is_serialized',array('class'=>'wide')); ?>
<div class='form_field'>
<?php echo form_checkbox(array(
'name'=>'is_serialized',
'id'=>'is_serialized',
'value'=>1,
'checked'=>($item_info->is_serialized)? 1 : 0)
);?>
</div>
</div>
<?php
echo form_submit(array(
'name'=>'submit',
'id'=>'submit',
'value'=>$this->lang->line('common_submit'),
'class'=>'submit_button float_right')
);
?>
</fieldset>
<?php
echo form_close();
?>
<script type='text/javascript'>
//validation and submit handling
$(document).ready(function()
{
$("#category").autocomplete("<?php echo site_url('items/suggest_category');?>",{max:100,minChars:0,delay:10});
$("#category").result(function(event, data, formatted){});
$("#category").search();
$('#item_form').validate({
submitHandler:function(form)
{
/*
make sure the hidden field #item_number gets set
to the visible scan_item_number value
*/
$('#item_number').val($('#scan_item_number').val());
$(form).ajaxSubmit({
success:function(response)
{
tb_remove();
post_item_form_submit(response);
},
dataType:'json'
});
},
errorLabelContainer: "#error_message_box",
wrapper: "li",
rules:
{
name:"required",
category:"required",
cost_price:
{
required:true,
number:true
},
unit_price:
{
required:true,
number:true
},
tax_percent:
{
required:true,
number:true
},
quantity:
{
required:true,
number:true
},
reorder_level:
{
required:true,
number:true
}
},
messages:
{
name:"<?php echo $this->lang->line('items_name_required'); ?>",
category:"<?php echo $this->lang->line('items_category_required'); ?>",
cost_price:
{
required:"<?php echo $this->lang->line('items_cost_price_required'); ?>",
number:"<?php echo $this->lang->line('items_cost_price_number'); ?>"
},
unit_price:
{
required:"<?php echo $this->lang->line('items_unit_price_required'); ?>",
number:"<?php echo $this->lang->line('items_unit_price_number'); ?>"
},
tax_percent:
{
required:"<?php echo $this->lang->line('items_tax_percent_required'); ?>",
number:"<?php echo $this->lang->line('items_tax_percent_number'); ?>"
},
quantity:
{
required:"<?php echo $this->lang->line('items_quantity_required'); ?>",
number:"<?php echo $this->lang->line('items_quantity_number'); ?>"
},
reorder_level:
{
required:"<?php echo $this->lang->line('items_reorder_level_required'); ?>",
number:"<?php echo $this->lang->line('items_reorder_level_number'); ?>"
}
}
});
});
</script>
Controller:
function view($item_id=-1)
{
$data['item_info']=$this->Item->get_info($item_id);
$data['item_tax_info']=$this->Item_taxes->get_info($item_id);
$suppliers = array('' => $this->lang->line('items_none'));
foreach($this->Supplier->get_all()->result_array() as $row)
{
$suppliers[$row['person_id']] = $row['company_name'] .' ('.$row['first_name'] .' '. $row['last_name'].')';
}
$data['suppliers']=$suppliers;
$data['selected_supplier'] = $this->Item->get_info($item_id)->supplier_id;
$data['default_tax_1_rate']=($item_id==-1) ? $this->Appconfig->get('default_tax_1_rate') : '';
$data['default_tax_2_rate']=($item_id==-1) ? $this->Appconfig->get('default_tax_2_rate') : '';
$this->load->view("items/form",$data);
}
Model:
<?php
class Item extends Model
{
/*
Determines if a given item_id is an item
*/
function exists($item_id)
{
$this->db->from('items');
$this->db->where('item_id',$item_id);
$query = $this->db->get();
return ($query->num_rows()==1);
}
/*
Returns all the items
*/
function get_all($limit=10000, $offset=0)
{
$this->db->from('items');
$this->db->where('deleted',0);
$this->db->order_by("name", "asc");
$this->db->limit($limit);
$this->db->offset($offset);
return $this->db->get();
}
function count_all()
{
$this->db->from('items');
$this->db->where('deleted',0);
return $this->db->count_all_results();
}
function get_all_filtered($low_inventory=0,$is_serialized=0,$no_description)
{
$this->db->from('items');
if ($low_inventory !=0 )
{
$this->db->where('quantity <=','reorder_level');
}
if ($is_serialized !=0 )
{
$this->db->where('is_serialized',1);
}
if ($no_description!=0 )
{
$this->db->where('description','');
}
$this->db->where('deleted',0);
$this->db->order_by("name", "asc");
return $this->db->get();
}
/*
Gets information about a particular item
*/
function get_info($item_id)
{
$this->db->from('items');
$this->db->where('item_id',$item_id);
$query = $this->db->get();
if($query->num_rows()==1)
{
return $query->row();
}
else
{
//Get empty base parent object, as $item_id is NOT an item
$item_obj=new stdClass();
//Get all the fields from items table
$fields = $this->db->list_fields('items');
foreach ($fields as $field)
{
$item_obj->$field='';
}
return $item_obj;
}
}
/*
Get an item id given an item number
*/
function get_item_id($item_number)
{
$this->db->from('items');
$this->db->where('item_number',$item_number);
$query = $this->db->get();
if($query->num_rows()==1)
{
return $query->row()->item_id;
}
return false;
}
/*
Gets information about multiple items
*/
function get_multiple_info($item_ids)
{
$this->db->from('items');
$this->db->where_in('item_id',$item_ids);
$this->db->order_by("item", "asc");
return $this->db->get();
}
/*
Inserts or updates a item
*/
function save(&$item_data,$item_id=false)
{
if (!$item_id or !$this->exists($item_id))
{
if($this->db->insert('items',$item_data))
{
$item_data['item_id']=$this->db->insert_id();
return true;
}
return false;
}
$this->db->where('item_id', $item_id);
return $this->db->update('items',$item_data);
}
/*
Updates multiple items at once
*/
function update_multiple($item_data,$item_ids)
{
$this->db->where_in('item_id',$item_ids);
return $this->db->update('items',$item_data);
}
/*
Deletes one item
*/
function delete($item_id)
{
$this->db->where('item_id', $item_id);
return $this->db->update('items', array('deleted' => 1));
}
/*
Deletes a list of items
*/
function delete_list($item_ids)
{
$this->db->where_in('item_id',$item_ids);
return $this->db->update('items', array('deleted' => 1));
}
/*
Get search suggestions to find items
*/
function get_search_suggestions($search,$limit=25)
{
$suggestions = array();
$this->db->from('items');
$this->db->like('name', $search);
$this->db->where('deleted',0);
$this->db->order_by("name", "asc");
$by_name = $this->db->get();
foreach($by_name->result() as $row)
{
$suggestions[]=$row->name;
}
$this->db->select('category');
$this->db->from('items');
$this->db->where('deleted',0);
$this->db->distinct();
$this->db->like('category', $search);
$this->db->order_by("category", "asc");
$by_category = $this->db->get();
foreach($by_category->result() as $row)
{
$suggestions[]=$row->category;
}
$this->db->from('items');
$this->db->like('item_number', $search);
$this->db->where('deleted',0);
$this->db->order_by("item_number", "asc");
$by_item_number = $this->db->get();
foreach($by_item_number->result() as $row)
{
$suggestions[]=$row->item_number;
}
//only return $limit suggestions
if(count($suggestions > $limit))
{
$suggestions = array_slice($suggestions, 0,$limit);
}
return $suggestions;
}
function get_item_search_suggestions($search,$limit=25)
{
$suggestions = array();
$this->db->from('items');
$this->db->where('deleted',0);
$this->db->like('name', $search);
$this->db->order_by("name", "asc");
$by_name = $this->db->get();
foreach($by_name->result() as $row)
{
$suggestions[]=$row->item_id.'|'.$row->name;
}
$this->db->from('items');
$this->db->where('deleted',0);
$this->db->like('item_number', $search);
$this->db->order_by("item_number", "asc");
$by_item_number = $this->db->get();
foreach($by_item_number->result() as $row)
{
$suggestions[]=$row->item_id.'|'.$row->item_number;
}
//only return $limit suggestions
if(count($suggestions > $limit))
{
$suggestions = array_slice($suggestions, 0,$limit);
}
return $suggestions;
}
function get_category_suggestions($search)
{
$suggestions = array();
$this->db->distinct();
$this->db->select('category');
$this->db->from('items');
$this->db->like('category', $search);
$this->db->where('deleted', 0);
$this->db->order_by("category", "asc");
$by_category = $this->db->get();
foreach($by_category->result() as $row)
{
$suggestions[]=$row->category;
}
return $suggestions;
}
/*
Preform a search on items
*/
function search($search)
{
$this->db->from('items');
$this->db->where("(name LIKE '%".$this->db->escape_like_str($search)."%' or
item_number LIKE '%".$this->db->escape_like_str($search)."%' or
category LIKE '%".$this->db->escape_like_str($search)."%') and deleted=0");
$this->db->order_by("name", "asc");
return $this->db->get();
}
function get_categories()
{
$this->db->select('category');
$this->db->from('items');
$this->db->where('deleted',0);
$this->db->distinct();
$this->db->order_by("category", "asc");
return $this->db->get();
}
}
?>
The item_number field in the view needs to be automatically filled incremented by one. Say the numbering series starts from 10001. The field should be prefilled with 10002 when New Item is added.
Ideas?
You can use
str_pad((int) $number,$n,"0",STR_PAD_LEFT);
Read more on: str-pad

Categories