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
Share on other sites

Thanks for that.

 

I'm a bit of a PHP novice and wondered if you could show me an example of a simple PHP script that will generate an 8-digit unique ticket ID.

 

Also, how would I post this into my existing SQL database?

 

Thanks,

 

BB2011

Link to comment
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.