CodeCharge Studio
search Register Login  

Visual PHP Web Development

Visually Create Internationalized Web Applications, Web Reports, Calendars, and more.

YesSoftware Forums -> CodeCharge Studio -> PHP

 Primary key editable in new record form

Print topic Send  topic

Author Message

Posts: 61
Posted: 03/04/2004, 6:13 PM

My client works with Project ID numbers and wants to be able to alter the Project ID number when creating a new Project record. The project ID will be referenced to many different tables and is unique to the record.

When creating a new record the project entry form should come up with the next available auto-increment number (5digit number with a format like 00335) in a text box. If needed the client should be able to modify this number the first time he enters a new record.

Question 1.
Should I still use the Project ID as my indexed table field or should I create an additional field as the primary index field.

Question 2.
What is the safest way to retrieve the next higher incremented Project ID number and show it in a text box. What safe guards can be taken if 2 people enter records at the same time. I tried with max(project_id +1) but I couldn’t get it to work properly.

Question 3.
How do I format so it always will show up as a five digit number. Like 00235

I work with PHP and MYSQL

Thanks for any hints

View profile  Send private message

Posts: 5971
Posted: 03/05/2004, 1:18 AM


Re: Q1
I believe that both methods should work. The first one is OK if this field is not auto-incremented. I probably use the 2nd one more often (by adding an autoincremented key field).

Re: Q2
I don't believe that there is a way to do this. At least logically I don't see how you could prevent multiple people from utilizing the same project number. This is probably the reason why almost all databases provide an autoincremented key - specifically to offer such functionality and resolve related issues. Though I may be wrong and you may be able to create some number reservation mechanism that reserves incremental number for each person. Still, I'd be concerned with using any program-driven method, rather than the database autoincrement feature.
A simplest way though (considering the risks or inconvenience) is to do what you wrote about max(project+id +1) and also set the "Unique" property to "Yes". This would warn the users that they are entering a duplicate number and they would be forced to re-enter it.

Re: Q3
Set the "Data Type" property to "Integer" and "Format" to "00000".
You may also consider utilizing the Input Mask as shown in "Data Entry page with Input Mask" example in CCS Example Pack.

Peter R.
YesSoftware Forums Moderator
For product support please visit
View profile  Send private message

Add new topic Subscribe to topic   

These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit

MS Access to Web

Convert MS Access to Web.
Join thousands of Web developers who build Web applications with minimal coding.

Home   |    Search   |    Members   |    Register   |    Login

Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by  and YesSoftware, Inc.