0

Hi friends,

I have a form to create a company details.. which will insert the details into a table.
For this table, I need to have a auto increment field as character..

when we have autoincreament as Integer... whenever the new company is created..the number will increase from 0, 1, 2, 3,..and so on..

I have added a hidden text field in the form and set the value as C1.
I need the values to get auto increament..so when ever the company is created..the value adds on as c1, c2, c3....and so on...
and these values has to be updated in the database also..
I am so lost in this...
I am working with php and mysql...
Your help is much appreciated...

Thanks.
Tryphy

3
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by phpbeginners
0

You need to do it manually i dont think mysql will do it automatically
First you may determine the max no using following query and then you may use it while inserting a new record

//determine id
//$id=SELECT max(substr(rollno,2))+1 FROM `alumni_job`;

$id='c'.$id;

insert into table (comp_id,name) values ('$id','$name');

Edited by urtrivedi: n/a

0

My suggestion is:

in your auto_increment inside your table.

Get the value of that auto_increment and join it in arguments "C" see $letter variable below.

$letter = "C";
$output = $letter.auto_increment (get this inside your table)

This question has already been answered. 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.