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

$GetTodoXProjSQL = "SELECT todoxproj_id FROM todoxproj WHERE xtodo_id = '$id'";
$GetTodoXProj = mysql_query($GetTodoXProjSQL);
$gettodoxproj = mysql_fetch_array($GetTodoXProj);

// if cross-reference exists, so update it
if ($gettodoxproj["todoxproj_id"]) {
    $xid = $gettodoxproj["todoxproj_id"];
    $TodoXProjSQL = "UPDATE todoxproj SET xproj_id = '$ForProject' WHERE todoxproj_id = '$xid' AND xtodo_id = '$id'";
}
// else cross-reference doesn't exist, so create it
else {
    $TodoXProjSQL = "INSERT INTO todoxproj (todoxproj_id, xtodo_id, xproj_id) VALUES (NULL, '$id', '$ForProject')";
}
$TodoXProj = mysql_query($TodoXProjSQL);

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