<?php
// first delete all appointments for this email
$q = "DELETE FROM `appointments` where `email_id`=$eid;";
$res = mysql_query($q, $link);

$q = "DELETE FROM `emails` WHERE `id`=$eid;";
if ($res = mysql_query($q, $link)) {
  $qs .="location=$locID";
}