close ad
Databridge V2 with MySQLi support IS Now Available!
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Need to insert unique values in two ID columns but can only have one autoincremental index

Thread began 6/29/2021 1:45 pm by MagsW | Last modified 7/01/2021 1:45 pm by Ray Borduin | 17 views | 2 replies |

MagsW

Need to insert unique values in two ID columns but can only have one autoincremental index

Hi Ray, ignore my last post which I've now deleted as I think I've worked out what my issue is.

I have 3 ID columns in a database - the main index ID which is an autoincrement column, and two other ID columns which in an ideal world would also be incremental but you can't have more than one autoincrement column in a database. I thought I could maybe use the random password generator to generate random numbers to insert in the column, but I've already used the rpw generator on the site so I get an error when I try to generate another one. How would I go about doing this, or is there another solution you can think of? Basically the other two columns (both integer type) already have data in some of the rows which needs to remain untouched, but if the rows are updated I would like unique numbers to be added to them both.

**UPDATE** I think I've solved it. I added two hidden fields with the value <?php echo rand(11000,99000);?> and set these to only show if the column values are currently empty. Then I added the post values to the update behavior. That way it will only write numbers to those fields if they are blank.

Sign in to reply to this post

Ray BorduinWebAssist

That will kind of work, but there is no guarantee the numbers will be unique.

Maybe set the hidden fields to 1000 + the ID Column when they are blank instead of using a random number. That way they will be unique since the ID column is unique.

Sign in to reply to this post
Did this help? Tips are appreciated...

MagsW

Good point, that's a much better idea, thanks!

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...