cripin Posted June 30, 2013 Share Posted June 30, 2013 REATE TABLE tops( id INT NOT NULL AUTO_INCREMENT, users_id INTEGER NOT NULL, title varchar(80), details varchar(250), type varchar(30) NOT NULL, site varchar(50), votes INT NOT NULL, facebook varchar(80), image varchar(100) NOT NULL, CONSTRAINT tops_pk PRIMARY KEY(id), CONSTRAINT user_fk FOREIGN KEY(users_id) REFERENCES users(id)); PHP Code: CREATE TABLE users( id int AUTO_INCREMENT NOT NULL, username varchar(60), password varchar(60), email varchar(80), premium enum('0','1') NOT NULL, timestamp int NOT NULL, CONSTRAINT users_pk PRIMARY KEY(id); When I register the data goes to the users table [working fine]Then when I add a server the data goes to tops table [working fine]However, users_id field in tops table doesn't update to the id of the user that added the server, it just remains 0. Could anyone help me find a problem here please Quote Link to comment Share on other sites More sharing options...
trq Posted June 30, 2013 Share Posted June 30, 2013 You need to do this yourself programatically. Foreign keys constraints have nothing to do with actually populating data, they just enforce rules in regards to what data can be stored and how its relationships might be declared. On a side note... why the ridiculous colors? Don't like our color scheme? Quote Link to comment Share on other sites More sharing options...
cripin Posted June 30, 2013 Author Share Posted June 30, 2013 i copied it and it remained like that for some reason. Also how would I go about to do it? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.