Can anyone tell me if this is the correct usage for this function. I am inserting into three tables with Employee table storing EmployeeID as auto_increment and the EmploymentDetails and EmergencyContacts just as ints.

$q = "INSERT INTO Employee (EmployeeID, Title, FirstName, MiddleName, Surname, Gender, DoB, NiNo, AddressLine1, AddressLine2, Town, Postcode, HomeTel,
		WorkTel, MobTel, Nationality, Ethnicity, Disability, DisabilityNeeds, MedicalProblems, IsCrbCheckRequired, CRBStatus, CentreName)
	      VALUES ('','$title', '$fn','$mn','$sn','$gender','$dob','$nino','$addline1','$addline2','$town','$pc','$htel','$wtel','$mtel','$nat','$eth',
	 	'$dis','$disneeds','$medprobs','$crbcheck','$crbstatus','$centre')";

  $r = @mysqli_query($dbc, $q);
$eid = mysql_insert_id($dbc);
 $qu = "INSERT INTO EmploymentDetails (EmployeeID, FirstName, Surname, ReportsTo, Reference, Team, HoursWorkedPerWeek, CentreName, FundingStream, Salary, StartDate)
 	VALUES ('$eid','$fn','$sn','$reportsto','$reference','$team','$hwpw','$centre','$stream','$salary','$startdate')";
$res = @mysqli_query($dbc, $qu);

$q1 = "INSERT INTO EmergencyContacts (EmployeeID, FiEmerConNA, FiEmerConAdd, FiEmerConTel, FiEmerConRel, SecEmerConNa, SecEmerConAdd, SecEmerConTel, SecEmerConRel)
	VALUES ('$eid','','','','','','','','')";
	$r1 = @mysqli_query($dbc, $q1);

    If the EmployeeID is the primary key, auto-increment, then you don't need to pass it in the INSERT command - MySql inserts that into the row automatically.

      Write a Reply...