PHP如何insert into Foreign Key值?

我想在貨品Table上的貨品,當賣家發佈他的貨品時賣家的id(由User table>貨品Table)會記錄在貨品上(加了Foreign Key).

CREATE TABLE `products` (
`pid` int(10) NOT NULL AUTO_INCREMENT,
`uid` int(8) NOT NULL,
`pname` varchar(50) NOT NULL,
`pcode` varchar(50) NOT NULL,
`description` TEXT NOT NULL,
`price` double(10,2) NOT NULL,
PRIMARY KEY (`pid`),
FOREIGN KEY (uid) REFERENCES users(uid)

$sql = "INSERT INTO product (uid, pname, pcode, description, price,) VALUES
('$uid', '$pname', '$pcode', '$description', '$price')";

是上面insert出了問題嗎?還是可以如何做?
Sign In or Register to comment.