proctk Posted July 30, 2006 Share Posted July 30, 2006 HiMy database has five tables four of which I have linked to master table with a FK. the linking column is the PK. My question when data is entered is the mastertable suposed to update the link column automaticly.I included some code I used to create my tables to give an idea what I'm trying to do.[code=php:0]code to create the tableinclude 'db.php'; mysql_query("CREATE TABLE children ( child_id int(25) NOT NULL auto_increment, childfirstname varchar(25) NOT NULL default '', childlastname varchar(25) NOT NULL default '', childdob varchar (25) default '', childsex varchar (25) default '', CONSTRAINT child_pk PRIMARY KEY (child_id) )")or die("Create table Error: ".mysql_error());?> [/code]code I used to upate the tables ( with editing to names)[code=php:0]mysql_query("ALTER TABLE masteradd CONSTRAINT fk_users FOREIGN KEY (user_id) REFERENCES users(users_id);") or die("Create table Error: ".mysql_error());?> [/code] Quote Link to comment https://forums.phpfreaks.com/topic/16043-php-mysql-fk/ 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.