Jump to content


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


Inserting data into two tables...

Recommended Posts

I have MySQL two tables set up like this:
CREATE TABLE `speakers`(
`speaker_id` INT(9) NOT NULL auto_increment,
`speaker` VARCHAR(30) NOT NULL,
PRIMARY KEY (speaker_id);

`cast_id` INT(9) NOT NULL auto_increment,
`speaker_id` INT(9) NOT NULL,
`title` VARCHAR(50) NOT NULL,
`filename` VARCHAR(20) NOT NULL,
`description` VARCHAR(200) NOT NULL,
`pubDate` VARCHAR(32) NOT NULL,
`size` INT(20) NOT NULL,
PRIMARY KEY (cast_id),
FOREIGN KEY (speaker_id) REFERENCES `speakers` (speaker_id) on delete cascade


I know how to insert data into one table...


$dbconn=mysql_connect("localhost", "username", "password");
$query=('INSERT "", $var1 INTO "speakers";');
$runquery=($query, $dbconn); //I know this isn't quite right, but you get the idea....

What I need to know is how to I edit the second table mentioned above and keep the FK relationship...I'm new to splitting up my tables...usually for something like this I would just leave it on one...but I want to learn how to do it the right way....thanks guys...

Share this post

Link to post
Share on other sites


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.