Location: PHPKode > projects > Mozart > Mozart-0.0.4/display.php
<?
// called from: contactlist.php
// description: this module would be more properly named displaycontact.php.  In addition to displaying
//              CONTACT information, it also hits the cross-reference tables to display all information
//              relating to this contact.
include("connect.inc");
include("reqlogin.inc");
include("userprefs.inc");

$AddrPhoneSQL = "SELECT * FROM contact, address, phone WHERE contact_id=$id and contact_id = address.fk_contact_id AND contact_id = phone.fk_contact_id AND address_id = phone.fk_address_id"; 
$OtherPhoneSQL = "SELECT * FROM contact, phone WHERE contact_id=$id and contact_id = phone.fk_contact_id AND phone.fk_address_id = 0";
$AddrPhone = mysql_query($AddrPhoneSQL); 
if (!($myrow = mysql_fetch_array($AddrPhone))) {
   $ContPhoneSQL = "SELECT * FROM contact, phone WHERE contact_id=$id AND contact_id = phone.fk_contact_id";
   $ContPhone    = mysql_query($AddrPhoneSQL);
   if (!($myrow = mysql_fetch_array($ContPhone))) {
      $ContAddrSQL = "SELECT * FROM contact, address WHERE contact_id=$id AND contact_id = address.fk_contact_id";
      $ContAddr    = mysql_query($ContAddrSQL);
      if (!($myrow = mysql_fetch_array($ContAddr))) {
         $ContactSQL = "SELECT * FROM contact WHERE contact_id=$id";
         $Contact    = mysql_query($ContactSQL);
         $myrow      = mysql_fetch_array($Contact);
     }
  }
}
print("<html>");
printf("<title>Mozart: Contact Detail for %s %s %s</title>", $myrow["first"], $myrow["middle"], $myrow["last"]);
?>
<body bgcolor=<? echo $bgcolor ?> text=<? echo $txtcolor ?>>
<center>
<? include("links.inc"); ?>
<br><br>
<?
print("<table border=0 cellspacing=0 cellpadding=5>");
printf("<tr><td><b>Name</b></td><td><i>%s %s %s %s</i></td></tr>", $myrow["sal"], $myrow["first"], $myrow["middle"], $myrow["last"]); 

$ctype = $myrow["contact_type"];
$ContactTypeSQL = "SELECT type_name FROM types WHERE type_id = '$ctype'";
$ContactType = mysql_query($ContactTypeSQL);
$ctype = mysql_fetch_array($ContactType);
printf("<tr><td><b>Type</b></td><td><i>%s</i></td></tr>", $ctype["type_name"]);
printf("<tr><td><b>Email</b></td><td><a href=\"mailto:%s\">%s</a></td></tr>", $myrow["email"], $myrow["email"]);
printf("<tr><td><b>URL</b></td><td><a href=\"%s\">%s</a></td></tr>", $myrow["website"], $myrow["website"]);
?>
<tr><td></td></tr>
<?   
do {
  $atype = $myrow["address_type"];
  $AddrTypeSQL = "SELECT type_name FROM types WHERE type_id = '$atype'";
  $AddrType = mysql_query($AddrTypeSQL);
  $atype = mysql_fetch_array($AddrType);
  printf("<tr><td><b>%s</b></td>", $atype["type_name"]);
  printf("<td>%s</td></tr>", $myrow["street01"]);
  if ($myrow["street02"]) {
	printf("<td></td><td>%s</td></tr>", $myrow["street02"]);?><BR><?
  }
  printf("<tr><td></td><td>%s, %s %s</td></tr>", $myrow["city"], $myrow["state"], $myrow["zip"]);
  printf("<tr><td></td><td>%s</td></tr>", $myrow["number"]);
  }
  while ($myrow = mysql_fetch_array($AddrPhone));

print("<tr><td><b>Other</b></td></tr>");
$OtherPhone = mysql_query($OtherPhoneSQL);
while ($myrow = mysql_fetch_array($OtherPhone)) {
  $ptype = $myrow["phone_type"];
  $PhoneTypeSQL = "SELECT type_name FROM types WHERE type_id = '$ptype'";
  $PhoneType = mysql_query($PhoneTypeSQL);
  $ptype = mysql_fetch_array($PhoneType);
  printf("<tr><td>%s</td><td>%s</td></tr>", $ptype["type_name"], $myrow["number"]);
}
$NotesSQL = "SELECT information FROM notes WHERE type = 'Contact' AND fk_key = '$id'";
$Notes    = mysql_query($NotesSQL);
$notes = mysql_fetch_array($Notes);
$note = $notes["information"];
printf("<tr><td><b>Notes</b></td><td>%s</td></tr>", $note);

// get all projects owned by this contact
$ProjOwnerSQL = "SELECT proj_id, name FROM project WHERE owner = '$id'";
$ProjOwner = mysql_query($ProjOwnerSQL);
if ($projowner = mysql_fetch_array($ProjOwner)) {
   printf("<tr><td><b>Projects<br>Owned</b></td><td><a href=\"projectdisplay.php?id=%s\">%s</a></td></tr>", $projowner["proj_id"], $projowner["name"]);
   while ($projowner = mysql_fetch_array($ProjOwner)) {
      printf("<tr><td></td><td><a href=\"projectdisplay.php?id=%s\">%s</a></td></tr>", $projowner["proj_id"], $projowner["name"]);
   }
}
// get all projects this contact is associated with
$ProjAssocSQL = "SELECT project.proj_id, project.name FROM project, contxproj WHERE xcont_id = '$id' AND xproj_id = project.proj_id";
$ProjAssoc    = mysql_query($ProjAssocSQL);
if ($projassoc = mysql_fetch_array($ProjAssoc)) {
   printf("<tr><td><b>Assoc'd<br>Projects</b></td><td><a href=\"projectdisplay.php?id=%s\">%s</a></td></tr>", $projassoc["proj_id"], $projassoc["name"]);
   while ($projassoc = mysql_fetch_array($ProjAssoc)) {
      printf("<tr><td></td><td><a href=\"projectdisplay.php?id=%s\">%s</a></td></tr>", $projassoc["proj_id"], $projassoc["name"]);
   }
}

?>
</table>
<br>
<?
include("links.inc"); 
?>
</center>
</body>
</html>
Return current item: Mozart