Location: PHPKode > projects > Mozart > Mozart-0.0.4/updapptxproj.inc
<?
// called from: updappt.php
// description: determines if appointment has been previously been associated with project.
//              if so, it updates APPTXPROJ.  otherwise, it inserts to APPTXPROJ.

$ApptXProj = "";
$GetApptXProjSQL = "SELECT apptxproj_id FROM apptxproj WHERE xappt_id = '$id'";
$GetApptXProj = mysql_query($GetApptXProjSQL);
$getapptxproj = mysql_fetch_array($GetApptXProj);

// if cross-reference exists, so update it
if ($getapptxproj["apptxproj_id"]) {
    $xid = $getapptxproj["apptxproj_id"];
    $ApptXProjSQL = "UPDATE apptxproj SET xproj_id = '$ForProject' WHERE apptxproj_id = '$xid' AND xappt_id = '$id'";
    $ApptXProj = mysql_query($ApptXProjSQL);
}
// else cross-reference doesn't exist, so create it
elseif ($ForProject != 0) {
    $ApptXProjSQL = "INSERT INTO apptxproj (apptxproj_id, xappt_id, xproj_id) VALUES (NULL, '$id', '$ForProject')";
    $ApptXProj = mysql_query($ApptXProjSQL);
}

$errno = mysql_errno($db);
$error = mysql_error($db);
if (!($errno == 0)) {
	$Message = "In updapptxproj.inc - Error $errno: $error";
}
?>
Return current item: Mozart