I'm having trouble getting my queries to insert properly.
this is my table structure
books(ISBN(pk), authorID(fk), formatID(fk), publisherID(fk), titleID(fk), yearPublished)
the ISBN and year are past directly via a form but the foreign keys are all auto incremented in their own tables. I was trying this:
mysql_query("insert into authors(authorName, authorBio) values('$author', '$bio')") or die(mysql_error());
$authorID = mysql_query("select authorID from authors where authorName = '$author' and authorBio = '$bio'") or die(mysql_error());
mysql_query("insert into publishers(pname) values('$publisher')") or die(mysql_error());
$publisherID = mysql_query("select publisherID from publishers where pname = '$publisher'") or die(mysql_error());
$formatID = mysql_query("select formatID from format where formatType = '$format'") or die(mysql_error());
mysql_query("insert into titles(authorID, title, summary) values('$authorID', '$title', '$summary')") or die(mysql_error());
$titleID = mysql_query("select titleID from titles where authorID = '$authorID' and title = '$title'") or die(mysql_error());
mysql_query("insert into books values('$ISBN', '$formatID', '$publisherID', '$year', '$titleID')") or die(mysql_error());
but all the foreign keys are getting inserted as zeros rather than the value they should be.
I was looking into select queries inside the insert but I'm not sure how that would work with the two values that don't need selecting.