Jump to content


Inserting data into two tables...

  • Please log in to reply
No replies to this topic

#1 dsartain

  • Members
  • PipPipPip
  • Advanced Member
  • 68 posts

Posted 16 September 2006 - 04:57 AM

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

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users