Jump to content

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?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.