Jump to content

SQL Database Help


ben_1uk

Recommended Posts

Hello everyone,

 

I have put together a HTML form in which data is being collected, then verified with a PHP script before being posted into a SQL database.

 

Is there anyway I can auto assign a unique ID to a database entry other than the default auto increment ID field?

 

I want to be able to assign random ID numbers to tickets for an event and was hoping that something could be achieved in SQL..?

 

Many thanks,

 

BB2011

Link to comment
https://forums.phpfreaks.com/topic/231373-sql-database-help/
Share on other sites

I have found numerous PHP scripts that will generate a unique number I can use for Ticket_ID, but because the existing data in my database is being populated by a user via a HTML form, I don't see how I can incorporate the use of such a script to correctly allocate a unique ID against a new database entry.

 

In other words, I cannot "post" the Ticket_ID to the database using the form so how would I go about posting this data?

 

Is there a way this can be handled automatically by SQL? I've been reading alot about GUID's, but I'm not sure how to create one as I have not created the database using code.

Link to comment
https://forums.phpfreaks.com/topic/231373-sql-database-help/#findComment-1190878
Share on other sites

If you are updating existing data, you probably could just add a column to the database and call it ticket_id and update the ticket id into that column.  Just have php generate the unique number, have php check to be sure this number is not already being used, if so create another id, check again, then update the number into the column. 

 

If you could post your html form code and the php you are using to update or post, I might could help you better.

 

 

Link to comment
https://forums.phpfreaks.com/topic/231373-sql-database-help/#findComment-1190942
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.