PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I am trying to insert values from the form into two different tables. The skill Name goes to the skill table, in which the Skill_ID is auto increment. and then I want to insert the weight and the last Skill_ID into the ID_Table.
My code so far is below, i no i have to use mysql_last_insert_ID to get the last ID in the skill table, but im not sure how....can anyone please help.
mysql_query("INSERT INTO Skill_ID
(Skill_ID, Skill_Name) VALUES('NULL', '$skill1' ) ")
or die(mysql_error());
$skill_id = mysql_insert_id($con); //$con is what you get when you do the mysql_connect()
//$skill_id will store the last inserted skill_id
//i believe that Skill_ID is an integer and you dont need those single quotes around it.
mysql_query("INSERT INTO ID_Table
(ID, Job_ID, Skill_ID, Weight) VALUES('NULL', '1',$skill_id, '$weight' ) ")
or die(mysql_error());
now my problem is how to add multiple skills and multiple weights into the tables. My current structure only lets me add one value per table, so 1 skill id, 1 weight, and 1 job id....what if I wanted to add 3 skills with 3 weights for any particular job id.