View Single Post
Old 02-17-2005, 02:04 AM   #1 (permalink)
Ste_Boro
Registered User
 
Join Date: Feb 2005
Posts: 1
Ste_Boro is on a distinguished road
Inserting the results of a select query into seperate tables

I'm building a music website using php/mysql for my final year project at university. I'm trying to do a select query on the band_id and then insert the result into 2 more tables that have the band id as a foreign key.

$result="select (`band_id`) from band
where band_name = '$band_name'";
mysql_query($result, $dbh);

//$band_name is the value entered into the edit box on my form and seen as the query returns $result I was thinking I could just slot it into the other queries and it would work like so:

$sql="INSERT INTO `member` (`band_id`)
VALUES($result)";
mysql_query($sql, $dbh);

$sql="INSERT INTO `user` (`band_id`)
VALUES($result)";
mysql_query($sql, $dbh);

Obviousley it doesn't work.

Any help would be appreciated.
Ste_Boro is offline   Reply With Quote