|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Checking for things already posted.
SO, im building a "geek dictionary" for my site at www.Geekswithpcs.com . I was wondering, how would i go about making it so that when i add an entry to the dictionary (via php-mysql databse) from the form i made to add them, is it possible to check the database to make sure that the entry wasnt already added. For example. if i made a entry for teh word "Overclock" and then, a few weeks later, a staff member enters the same word, can i have it so that it will check to see if the mysql table already contains this word in a specified field?
|
|
#2
|
|||
|
|||
|
The best way to do this is to set the field containing the word (i.e. "overclock") as a UNIQUE field. See the MySQL documention for info on how to do this.
Best Regards, Joe of 4Life
__________________
Check out 4Life today! |
|
#3
|
|||
|
|||
|
If you set that field as unique and then someone tries to add a row that already exists will an error be returned or will mysql just not add it without reporting so?
If the latter is the case then you can query the database first - $query = 'SELECT * FROM table WHERE field="overclock"' If you run that query and it returns a row then its already in the database. If not then you can add the new row and know its not already there. Hope that helps, -KM- |
|
#4
|
|||
|
|||
|
Quote:
Suppress the query: PHP Code:
You can test the result scalar if needed PHP Code:
__________________
~ Joe Penn We work for free to help make this a valuable resource on the internet. Do you appreciate the help - did we provide help that will help you prosper and help that has contributed to sharpening your current skill set? Show your appreciation and purchase something from our Amazon Wishlist's - it's simple and a great way to say thank you. |
![]() |
| Viewing: Dev Articles Community Forums > Programming > General Programming Help > Checking for things already posted. |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|