Jump to content

Could somebody help me here please


cripin

Recommended Posts

REATE TABLE tops(
  
id INT NOT NULL AUTO_INCREMENT,
  
users_id INTEGER NOT NULL,
  
title varchar(80),
  
details varchar(250),
  
type varchar(30NOT NULL,
  
site varchar(50),
  
votes INT NOT NULL,
  
facebook varchar(80),
  
image varchar(100NOT NULL,
  
CONSTRAINT tops_pk PRIMARY KEY(id),
  
CONSTRAINT user_fk FOREIGN KEY(users_idREFERENCES 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

Link to comment
https://forums.phpfreaks.com/topic/279708-could-somebody-help-me-here-please/
Share on other sites

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?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.