I am inserting data into, table1. After this data is inserted I am trying to insert data into table2 to based off table1 data. Table2 has FK from table one that I am referencing. This is how I have my inserts setup up right now (this does not work). Any help on how to clean this up and make it work correctly would be greatly appreciated.
Thank you,
Mike
$r = mysqli_query($dbc, "INSERT INTO player(gamedate, home, away, goalsfor, goalsagainst, yellowcards, redcards) VALUES ('$gamedate','$home','$away','$goalsfor','$goalsagainst','$yellowcards','$redcards')"); if (mysqli_affected_rows($dbc) == 1) { echo "Added game successfully"; $playerid = mysql_insert_id(); $gameresult = mysqli_query($dbc, "INSERT INTO game(player_id, pposition, pgoalsfor, pgoalsagainst, psog, ppk, pyellowcards, predcards) VALUES ('$playerid','$pposition','$pgoalsfor','$pgoalsagainst','psog','ppk','pyellowcards','predcards')"); if (mysqli_affected_rows($dbc) == 1) { echo "Added Individual Stats successfully"; mysqli_close(); } else { echo "There was an error. Your stats were not added."; mysqli_close(); } mysqli_close(); } else { echo "There was an error. Your game was not added."; mysqli_close(); }
Thank you,
Mike