1 |
dpavlin |
1.1 |
<? |
2 |
|
|
include_once( "global.php" ); |
3 |
|
|
include_once( "dbconnect.php" ); |
4 |
|
|
include_once( "$phormationdir/displaytable.php" ); |
5 |
|
|
|
6 |
|
|
|
7 |
|
|
$params["query"] = "select id,firstname,lastname,phone,email,typeid from contact"; |
8 |
|
|
$params["defaultsort"] = "lastname"; |
9 |
|
|
$params["editlink"] = "contact_detail.php"; |
10 |
|
|
$params["newlink"] = "contact_detail.php"; |
11 |
|
|
$params["addmultiplelink"] = "contact_multi.php"; |
12 |
|
|
$params["delquery"] = "delete from contact where id = "; |
13 |
|
|
$params["predelete_hook"] = "my_predelete_fcn"; |
14 |
|
|
$params["key"] = "id"; |
15 |
|
|
|
16 |
|
|
$fields[] = "firstname"; $names[] = "First Name"; |
17 |
|
|
$fields[] = "lastname"; $names[] = "Last Name"; |
18 |
|
|
$fields[] = "phone"; $names[] = "Phone Number"; |
19 |
|
|
$fields[] = "email"; $names[] = "Email Address"; |
20 |
|
|
$fields[] = "typeid"; $names[] = "Type"; |
21 |
|
|
|
22 |
|
|
function my_predelete_fcn( $record_id ) |
23 |
|
|
{ |
24 |
|
|
// since we also have to delete a photo when we delete this record, |
25 |
|
|
// we write a short function to do this. We pass the name of the function |
26 |
|
|
// to Phormation in the "params" array, so that it will call this |
27 |
|
|
// function just before deleting a record from the database. |
28 |
|
|
$query = "select photo from contact where id = $record_id"; |
29 |
|
|
$result = pg_exec( $query ); |
30 |
|
|
if( $result ) { |
31 |
|
|
$array = pg_fetch_array( $result, 0 ); |
32 |
|
|
$filename = "/home/jdhildeb/public_html/phexample/pics/" . trim( $array[0] ); |
33 |
|
|
@unlink( $filename ); |
34 |
|
|
} |
35 |
|
|
} |
36 |
|
|
|
37 |
|
|
table_index( $fields, $names, $params ); |
38 |
|
|
?> |