am having a problem in incrementing the number automically into the database every the when save. The initial number i want it to be 001 in a text box and when i save it, it should increment into 002 and so on. And every time i load the web page after i have close it, it should read the previous number which i stored last into the database.

do you get the previous number, if so then after you increment it you should format it to string to make it 002. if you are not getting the previous number correctly you should add order by id desc.

Fake signature snipped

You should definately post a little more about your situation?
You can simply do like this:

//Pseudocode.
//1st suggestion:
Login(){
    return (retrive_previous_id());
}
SetLogIn(){
    this->id=Login();
}
InsertInfo();
Logout(){
    //increment id.
    set_previous_id(id++);
}

// 2nd suggestion:
Login(){
    return (retrive_previous_id());
}
SetLogIn(){
    //here you increment the id.
    this->id=Login()+1;
}
InsertInfo();
Logout(){
    set_previous_id(id);
}

1st example retrives the previous id which is already incremented at the last logout.
2nd example retrives the previous id, which in the process is incremented.

These are some suggestions, use whatever you like;).

Which DBMS are you using? Most modern database engines have some sort of support for autoincrementing integers, which would make a lot more sense for most purposes than a text field as a primary key.

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.