0,0 → 1,61 |
<?php |
|
include_once('includes/common.php'); |
Prolog(); |
|
if(array_key_exists('delete', $_POST)) { |
$id = $_POST['id']; |
$db->query_params("delete from telbook_entries where entry_person=$1", array($id)); |
$db->query_params("delete from telbook_persons where person_id=$1", array($id)); |
|
header("Location: telbook_list.php"); |
$g_display->add_text('Information deleted successfully'); |
} |
else if(array_key_exists('update', $_POST)) { |
$id = $_POST['id']; |
$person_name = $_POST['person_name']; |
$person_comment = $_POST['person_comment']; |
$person_category = ($_POST['person_category'] == '' ? NULL : $_POST['person_category']); |
|
if($id) { |
$db->query_params("update telbook_persons set" |
. " person_name=$2, person_comment=$3, person_category=$4" |
. " where person_id=$1", |
array($id, $person_name, $person_comment, $person_category)); |
} |
else { |
$db->query_params("insert into telbook_persons" |
. " (person_name, person_comment, person_category) values ($1, $2, $3)", |
array($person_name, $person_comment, $person_category)); |
|
$db->query("select currval('telbook_persons_person_id_seq')"); |
if($line = $db->fetch_row_idx()) { |
$id = $line[0]; |
} |
} |
|
$db->query_params("delete from telbook_entries where entry_person=$1", array($id)); |
foreach($_POST as $key => $value) { |
if(substr($key, 0, strlen('entry_title-')) == 'entry_title-') { |
$entry_count = substr($key, strlen('entry_title-')); |
|
$entry_title = $_POST['entry_title-' . $entry_count]; |
$entry_value = $_POST['entry_value-' . $entry_count]; |
$entry_comment = $_POST['entry_comment-' . $entry_count]; |
|
if($entry_value) { |
$db->query_params("insert into telbook_entries" |
. " (entry_value, entry_title, entry_person, entry_comment)" |
. " values ($1, $2, $3, $4)", |
array($entry_value, $entry_title, $id, $entry_comment)); |
} |
} |
} |
|
header("Location: telbook_list.php"); |
$g_display->add_text('Information saved successfully'); |
} |
|
Epilog(); |
|
?> |
Property changes: |
Added: svn:mergeinfo |