Location: PHPKode > projects > Communication Kit > programs/live/contact_maint_inc.php
<?php
class ck_contact_maint {
  var $page_ref = '';
  var $ob = "" ; //order by
  var $ob_dir = "" ; //order by direction
  var $ob_next = "" ; //order by next
  var $update_actions = Array('del');
  var $display_actions = Array('dummy');
  function update_page($action){
    global $error_text;
    $req_contact_id = (isset($_REQUEST["contactid"])) ? $_REQUEST["contactid"] : "" ;
    $filter = (isset($_POST["filter"])) ? $_POST["filter"] : "all" ;
    if ($action=="del") {
      $sql = mysql_query("SELECT * FROM ".CONTACTS."
        WHERE contact_id ='$req_contact_id'")
      or die (mysql_error());
      $check = mysql_num_rows($sql);
      if ($check == 1){
        $sql = mysql_query("DELETE FROM ".CONTACTS."
          WHERE (contact_id = '$req_contact_id')")
        or die (mysql_error());
        $sql = mysql_query("DELETE FROM ".CONTACT_CATS."
          WHERE (contact_id = '$req_contact_id')")
        or die (mysql_error());
      } else {
        echo "invalid contact name!";
      }
    }
  }
  function display_page($action){
    $req_contact_id = (isset($_REQUEST["contactid"])) ? $_REQUEST["contactid"] : "" ;
    $filter = (isset($_POST["filter"])) ? $_POST["filter"] : "all" ;
    $sql = mysql_query("SELECT * FROM ".CATEGORIES."
      WHERE 1
      ORDER BY category_desc");
    $no_of_categories = mysql_num_rows($sql);
    if ($no_of_categories>0) {
      print "<form name=contact_form method=post action=".$_SERVER['PHP_SELF']."?page_ref=$this->page_ref>";
      print "<table cellpadding=8><tr>
<td class=small_text>Choose all mailing list entries or restrict to special interests only:</td>
<td class=reset><select name=filter onchange=\"document.contact_form.submit();\">
<option value='all'>All Contacts</option>";

      while($row = mysql_fetch_array($sql)){
        foreach( $row AS $key => $val ){
          $$key = stripslashes( $val );
        }
        $select_text = ($filter==$category_id) ? "selected" : "" ;
        print "<option value=$category_id $select_text>$category_desc</option>\n";
      }
      print "</select></td></tr></table></form>";
    }
    print "<center><table cellpadding=4>
<tr><th>Contact Email</th>
<th>Sign Up Date</th>
</tr>";
    $sql = mysql_query("SELECT * FROM ".CONTACTS."
      WHERE 1");
    while($row = mysql_fetch_array($sql)){
      foreach( $row AS $key => $val ){
        $$key = stripslashes( $val );
      }
      if ($filter<>"all") {
        $sql_cats = mysql_query("SELECT * FROM ".CONTACT_CATS."
          WHERE  contact_id = '$contact_id' AND
          contact_cat_id = '$filter'");
        $no_of_cats = mysql_numrows($sql_cats);
      }
      if (($filter=="all")||($no_of_cats==1)) {
        print "<tr  onmouseover=\"setPointer(this, '".$_SESSION['sess_hlight_backg_color']."', '".$_SESSION['sess_color_0']."')\" onmouseout=\"setPointer(this, '".$_SESSION['sess_color_0']."', '".$_SESSION['sess_color_0']."')\">";
        print  "<td class=small_text>$contact_email</td>
<td class=small_text>$contact_signup_date</td>
<td class=small_text align=center><a href='".$_SERVER['PHP_SELF']."?page_ref=$this->page_ref&action=del&contactid=$contact_id'>Delete</a></td>
</tr>\n";
      }
    }
    print "</table></center>";
  }
}
?>
Return current item: Communication Kit