Location: PHPKode > projects > Mozart > Mozart-0.0.4/deleteprj.php
<?
// called from: contactlist.php, delproject.php
// description: deletes all entries associated with a given PROJECT
//
include("connect.inc");
include("reqlogin.inc");

// they said to delete it, so here we go
// delete the project
$DelProjectSQL = "DELETE FROM project WHERE proj_id=$id";
$DelProject    = mysql_query($DelProjectSQL);

// delete the associated appointments
$ApptIDSQL = "SELECT xappt_id FROM apptxproj WHERE xproj_id=$id";
$ApptID    = mysql_query($ApptIDSQL);
while ($apptid = mysql_fetch_array($ApptID)) {
   $delapptid       = $apptid["xappt_id"];
   $DelApptSQL      = "DELETE FROM appointment WHERE appt_id=$delapptid";
   $DelAppt         = mysql_query($DelApptSQL);
   $DelContXApptSQL = "DELETE FROM contxappt WHERE xappt_id=$delapptid";
   $DelContXAppt    = mysql_query($DelContXApptSQL); 
   $DelUserXApptSQL = "DELETE FROM userxappt WHERE xappt_id=$delapptid";
   $DelUserXAppt    = mysql_query($DelUserXApptSQL);
}
// delete the contact/project cross-reference entries
$DelContXProjSQL = "DELETE FROM contxproj WHERE xproj_id=$id";
$DelContXProj    = mysql_query($DelContXProjSQL);

// delete the appointment/project cross-reference entries
$DelApptXProjSQL = "DELETE FROM apptxproj WHERE xproj_id=$id";
$DelApptXProj    = mysql_query($DelApptXProjSQL);

// delete the associated to do items
$ToDoIDSQL = "SELECT xtodo_id FROM todoxproj WHERE xproj_id=$id";
$ToDoID = mysql_query($ToDoIDSQL);
while ($todoid = mysql_fetch_array($ToDoID)) {
   $deltodoid       = $todoid["xtodo_id"];
   $DelToDoSQL      = "DELETE FROM todo WHERE todo_id=$deltodoid";
   $DelToDo         = mysql_query($DelToDoSQL);
   $DelUserXTodoSQL = "DELETE FROM userxtodo WHERE xtodo_id=$deltodoid";
   $DelUserXTodo    = mysql_query($DelUserXTodoSQL);
}

// delete the todo/project cross-reference entries
$DelToDoXProjSQL = "DELETE FROM todoxproj WHERE xproj_id=$id";
$DelToDoXProj    = mysql_query($DelToDoXProjSQL);

// delete the user/project cross-reference entries
$DelUserXProjSQL = "DELETE FROM userxproj WHERE xproj_id=$id";
$DelUserXProj    = mysql_query($DelUserXProjSQL);

// and we're done.  whew!
$Message = "Project Successfully Deleted";
include("projectlist.php")
?>
Return current item: Mozart