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

Recommended Answers

All 2 Replies

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');

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)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.