This topic is locked

Add record, with data from another table.

3/29/2010 12:54:45 PM
PHPRunner General questions
K
Khris author

I'm trying to add a new record, and at the same time, pull some information from another table rather than having the user fill it in again. Can someone direct me as to where I'm going wrong?



Add Page: Before Display
global $conn;

$strSQLSelect = "SELECT Emp_FirstName, Emp_LastName, Emp_EmailAddress, Emp_BranchID FROM Employees WHERE Emp_Username = '".$_SESSION["UserID"]."'";

$rsSelect = db_query($strSQLSelect,$conn);

$data=db_fetch_array($rsSelect);
$xt->assign("Emp_FirstName", $data["Emp_FirstName"]);

$xt->assign("Emp_LastName", $data["Emp_LastName"]);

$xt->assign("Emp_EmailAddress", $data["Emp_EmailAddress"]);

$xt->assign("Emp_BranchID", $data["Emp_BranchID"]);
K
Khris author 3/29/2010

Figured it out after a bunch of reading/searching. See below.
Add Page: Before Display
global $conn;

$strSQLSelect = "SELECT Emp_FirstName, Emp_LastName, Emp_EmailAddress, Emp_BranchID FROM Employees WHERE Emp_Username = '".$_SESSION["UserID"]."'";

$rsSelect = db_query($strSQLSelect,$conn);

$data=db_fetch_array($rsSelect);
$xt->assign("Emp_FirstName_editcontrol", $data["Emp_FirstName"]);

$xt->assign("Emp_LastName_editcontrol", $data["Emp_LastName"]);

$xt->assign("Emp_EmailAddress_editcontrol", $data["Emp_EmailAddress"]);

$xt->assign("Emp_BranchID_editcontrol", $data["Emp_BranchID"]);