Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PHP / MYSQL Help

Status
Not open for further replies.

jutler

Technical User
Joined
Jun 3, 2004
Messages
1
Location
GB
I work in a small enterprise as a systems admin. I am currently just finishing up an intranet site and am using php with mySQL on a Red hat 9 Linux machine.
I want to incorporate a fault logging system into this intranet site, whereby users can log a fault through a php page and it is entered into a mySQL db.
The fields which i will use in the db are job_no, name, contact_no, description, status, notes.
The problem i have is that i want the job_no to be a unique number which does not get repeated because i want users to be able to use the job_no to check the status of their problem. I have decided to use julian dates, which are assigned to the job when the user goes to the intranet fault logging page. This should not be able to be changed by the user. The PHP page should assign the value to the job and pass it to the mySQL db and insert it into the job_no column.
Anyone have an idea of how i can implement this? any help would be much appreciated
 
why don't you use an auto-increment column to insert unique values and then simply use another select to see what that number is and display it to the user.

another way is to do a select max(job_no)+1 and use this as a job_no but it's not as safe as auto-increment columns.
 
I agree with DaZZleD's advice of using an auto_increment column.

However, instead of using another SELECT query to fetch the auto_increment column id that was generated with your last INSERT query, just use mysql_insert_id().



Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top