Location: PHPKode > projects > Mozart > Mozart-0.0.4/emailxref.php
<?
// called from: showmail.php
// description: creates emailxref entry between contact, project and email id from gmail
//
include("connect.inc");
include("reqlogin.inc");

// first we want to read emailxref to see if a record already exists
$CheckRecSQL  = "SELECT xcont_id, xproj_id FROM emailxref WHERE xemail_id = '$emailno'";
$CheckRec     = mysql_query($CheckRecSQL);
$checkrec     = mysql_fetch_array($CheckRec);
$errno        = mysql_errno($db);

// if no contact or project is associated with the email, delete the entry
if (($SelectedContact == 0) AND ($SelectedProject == 0)) {
    $EmailXRefSQL = "DELETE FROM emailxref WHERE xemail_id = '$emailno'";
}
// if a record exists, update the record
elseif (($checkrec["xcont_id"]) OR ($checkrec["xproj_id"])) {
    $EmailXRefSQL = "UPDATE emailxref SET xcont_id = '$SelectedContact', xproj_id= '$SelectedProject' WHERE xemail_id = '$emailno'";
}
// otherwise, create a new entry
else { 
    $EmailXRefSQL = "INSERT INTO emailxref (xemail_id, xcont_id, xproj_id) VALUES ($emailno, $SelectedContact, $SelectedProject)";
}
$EmailXRef    = mysql_query($EmailXRefSQL); 

$errno = mysql_errno($db);
$error = mysql_error($db);

if ($errno == 0) {
    $Message = "Association Successfully Created";
}
else {
    $Message = "Error in emailxref.php $errno: $error SQL: $EmailXRefSQL";
}

include("showmail.php");
exit;
?>
Return current item: Mozart