Jump to content

Inserting data into two tables...


dsartain

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...
Link to comment
Share on other sites

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.