> I want the user to add products into the order table but I
> don't want it to add the same product two or more times into
> the table.
> I made a condition and for a test I used ProductID s and I
> put them in the condition myself just to test it.
> If I enter the same productID which is in the table it works
> fine but when I enter the second record it doesn't work at
> all!. I think it may need to be looped but have no idea how to that.
> Please please help me. <cfif conditional.ProductID EQ 2> here
> 2 is the second productID which IS in my database but still
> it enters data into the database while it shouldn't!
> this is my code
>
> <cfquery name="conditional" datasource="test_shop">
> SELECT *
> FROM orders
> </cfquery>
>
> <cfif conditional.ProductID EQ 2>
>
> It's not possible to add the same product.
>
> <cfelse>
>
> <cfquery datasource="Test_Shop">
> INSERT INTO orders (productID)
> VALUES ("#FORM.addme#")
> </cfquery>
> Thanks for inserting new product
> </cfif>
Presumably, you have more than one record in the "orders" table. If you
select all the records, then refer to conditional.ProductID outside the
context of a loop, you will get the first ProductID in the recordset.
Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/
Fig Leaf Training: Adobe/Google/Paperthin Certified Partners
http://training.figleaf.com/
WebManiacs 2008: the ultimate conference for CF/Flex/AIR developers!
http://www.webmaniacsconference.com/
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to
date
Get the Free Trial
http://ad.doubleclick.net/clk;160198600;22374440;w
Archive:
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:298535
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4