This topic is locked

unique number

6/11/2010 5:27:33 AM
PHPRunner General questions
M
munkeh author

Hello,
Is there a way to make sure that a number can only be used once in a table?

Can this be done via phprunner?
regards,

T
Tempus_Erus 6/13/2010



Hello,
Is there a way to make sure that a number can only be used once in a table?

Can this be done via phprunner?
regards,


Hi,
Check out:
http://xlinesoft.com/phprunner/docs/check_if_specific_record_exists.htm
might be of help?
Ady

lewisgr 6/14/2010



Hello,
Is there a way to make sure that a number can only be used once in a table?

Can this be done via phprunner?
regards,


The easiest way I found is to index the field and the set the Index type to Unique.

M
munkeh author 6/16/2010



The easiest way I found is to index the field and the set the Index type to Unique.


Hi,
Im pretty new to this stuff. Could you please explain how to do this?

lewisgr 6/17/2010



Hi,
Im pretty new to this stuff. Could you please explain how to do this?


What Kind of DB backend are you using? If you are using MySQL:
ALTER TABLE tablenameADD UNIQUE fieldname(fieldname);
You might get an error if you have data already in there. When I did this even Nulls and empty string count. What I did so I could change the code was anything that was null or empty strings I put the PrimaryKey number in there as a place holder.

S
swanside 6/17/2010



Hello,
Is there a way to make sure that a number can only be used once in a table?

Can this be done via phprunner?
regards,


There are a couple of ways, If you are using MySQL as a database. You can set the field for the number up as an INT, make it Primary and Auto increment. That way it will add a new number everytime you add a new line.

The other way, is just click on the Unique field for the filed you require. If there are no numbers the same it will apply it, otherwise it will not allow you to do it.

If you are using MySQL, check out PHPMyAdmin to administer your database and perform these actions.