[UPHPU] Sequentially number records with php/mysql

Brent Wilkinson brent at air2data.com
Wed Nov 10 10:56:54 MST 2004

Autoincrement is the way to go

Sample line

alter table <table> add <column> int(11) not null auto_increment, add
primary key (<column>); 

Brent Wilkinson
Tech Manager

-----Original Message-----
From: uphpu-bounces at uphpu.org [mailto:uphpu-bounces at uphpu.org] On Behalf Of
Wade Preston Shearer
Sent: Wednesday, November 10, 2004 10:54 AM
To: uphpu at uphpu.org
Subject: Re: [UPHPU] Sequentially number records with php/mysql

> I'm setting up a way for people to order business cards from our 
> company.
> I have it all finished, but right now I'm just using random #'s to 
> give them a job#. What's the easiest way to give them a sequential job 
> number? I don't want a database full of unfulfilled orders, but I'm 
> guessing that making a record in the db for each new customer is the 
> way to go, and then delete the record if the person doesn't order, 
> right?
> Anyway, just wanted to knwo what you guys thought.

You can have the database automatically increment and assign a unique ID to
each new record.

For example, in MySQL, you can set a column to do this with something

	pid int unsigned auto_increment primary key,

More information about the UPHPU mailing list