Jump to content

Archived

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

dsartain

Inserting data into two tables...

Recommended Posts

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


CREATE TABLE `RSS_info`(
`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
); TYPE=MYISAM

[/code]


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

[code]
<?php
$var1=$_POST['value_name'];

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

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.