Deleting records from mySQL


#1

My project has users log in and create orders. They create their own Order Numbers. What I need to do is have them be able to delete their own orders.
Eg. User #1 may create an Order #101, and User #2 also has an Order with #101.

Users can view their orders which are displayed in a table. In each table row, I have a delete link that will delete that order, but I don’t want User 1 being able to delete orders from any other users that have the same Order Number.

Thanks.
cracker


#2

Wouldn’t you just specify both variables?

e.g.

DELETE FROM orders WHERE user = 1 AND order = 101;


#3

Matt, thanks for the reply. I figured I need to have the query like that, however, I have set it up so that the user is viewing a table that is populated with his orders. At the end of each row, I have a DELETE link. I would just like the user to be able click on this link and the delete query is activated and the order is removed from the database.
The only way around it at the moment is I have appended their userID to the order number they create. So if their userID = 10 and they create and order number 5, then the actual orderID sent to the database will be 1015. Since the first two digits will be unique then I this will work. Eg. if user 11 creates an order 5 then the actual order number will be 115. I would dearly like to hide their userID in the order number somehow so it doesn’t look too confusing to them. If they create an order number 10, I would like them to be able to see that order number and not 1010 or 1110. I am not sure if I can include in the query
DELETE FROM ‘orders’ WHERE OrderID = ‘5’ AND UserID = $SESSION_ID_UserID


#4

Proprio niente nei registri (e dico assolutamente nulla hanno E_ALL & ~ E_DEPRECATED & ~ E_STRICT non ha permesso una cosa -! (Questa intera questione sembra essere un Ustream Ubuntu 14.04 gli altri mono hanno avuto problemi con la registrazione degli errori php su 14.04).
Mi sto muovendo lo sviluppo di un Bitnami WAMP stack su un Windows 7 installare VirtualBox. Riporterà indietro quando so di più