prefix."addressbook SET organisation = '".$wpdb->escape($_POST['organisation'])."', first_name = '".$wpdb->escape($_POST['first_name'])."', surname = '".$wpdb->escape($_POST['surname'])."', email = '".$wpdb->escape($_POST['email'])."', website = '".$wpdb->escape($_POST['website'])."', address_line1 = '".$wpdb->escape($_POST['address_line1'])."', address_line2 = '".$wpdb->escape($_POST['address_line2'])."', suburb = '".$wpdb->escape($_POST['suburb'])."', postcode = '".$wpdb->escape($_POST['postcode'])."', state = '".$wpdb->escape($_POST['state'])."', country = '".$wpdb->escape($_POST['country'])."', phone = '".$wpdb->escape($_POST['phone'])."'"; $wpdb->query($sql); ?>

Address added. Continue »

prefix."addressbook WHERE id='".$wpdb->escape($_GET['id'])."'"; $row = $wpdb->get_row($sql); if ($_GET['confirm']=='yes') { $wpdb->query("DELETE FROM ".$wpdb->prefix."addressbook WHERE id='".$wpdb->escape($_GET['id'])."'"); echo '

The address has been deleted. Continue »

'; } else { echo "

Are you sure you want to delete the following address?

".$row->first_name." ".$row->surname."
".$row->organisation."
".$row->email." ".$row->phone."
".$row->address_line1."
".$row->address_line2."
".$row->suburb." ".$row->postcode."
".$row->state."
".$row->country."

[Yes]      [No]

"; } } else if ($_GET['action']=='edit') { $sql = "SELECT * FROM ".$wpdb->prefix."addressbook WHERE id='".$wpdb->escape($_GET['id'])."'"; $row = $wpdb->get_row($sql); if ($_POST['save']) { $wpdb->query("UPDATE ".$wpdb->prefix."addressbook SET first_name = '".$wpdb->escape($_POST['first_name'])."', surname = '".$wpdb->escape($_POST['surname'])."', organisation = '".$wpdb->escape($_POST['organisation'])."', email = '".$wpdb->escape($_POST['email'])."', phone = '".$wpdb->escape($_POST['phone'])."', address_line1 = '".$wpdb->escape($_POST['address_line1'])."', address_line2 = '".$wpdb->escape($_POST['address_line2'])."', suburb = '".$wpdb->escape($_POST['suburb'])."', postcode = '".$wpdb->escape($_POST['postcode'])."', state = '".$wpdb->escape($_POST['state'])."', country = '".$wpdb->escape($_POST['country'])."', website = '".$wpdb->escape($_POST['website'])."' WHERE id ='".$wpdb->escape($_GET['id'])."'"); echo '

The address has been updated. Continue »

'; } else { ?>

Edit Address

prefix."addressbook"; If ($wpdb->get_var("SHOW TABLES LIKE '$table_name'")!=$table_name || get_option("addressbook_version")!=$addressbook_version ) { // Call the install function here rather than through the more usual // activate_blah.php action hook so the user doesn't have to worry about // deactivating then reactivating the plugin. Should happen seemlessly. _addressbook_install(); echo '

The Addressbook plugin (version '.get_option("addressbook_version").') has been installed or upgraded.

'; } ?>
Select an address from below to see its details displayed here.

This is version of the Addressbook plugin by Sam Wilson.
Please report any bugs and feature requests at samwilson.id.au/blog/addressbook-plugin.
Thankyou.

Add new address ↓

Addressbook

prefix."addressbook ORDER BY first_name"; $results = $wpdb->get_results($sql); foreach ($results as $row) { echo""; } ?>
NameOrganisationEmail addressPhone number
".$row->first_name." ".$row->surname." ".$row->organisation." ".$row->email." ".$row->phone."
id."-info' style='display:none'>

[Edit] [Delete]

".$row->first_name." ".$row->surname."
".$row->email." ".$row->phone."

".$row->address_line1."
"; if ($row->address_line2) echo $row->address_line2."
"; echo $row->suburb." ".$row->postcode."
".$row->state."
".$row->country."

"; } ?>

Add Address

website; $out = '
'; return $out; } function _addressbook_install() { global $wpdb, $addressbook_version; $table_name = $wpdb->prefix."addressbook"; $sql = "CREATE TABLE " . $table_name . " ( id mediumint(9) NOT NULL AUTO_INCREMENT, first_name tinytext NOT NULL, surname tinytext NOT NULL, organisation tinytext NOT NULL, email tinytext NOT NULL, phone tinytext NOT NULL, address_line1 tinytext NOT NULL, address_line2 tinytext NOT NULL, suburb tinytext NOT NULL, postcode tinytext NOT NULL, state tinytext NOT NULL, country tinytext NOT NULL, website VARCHAR(55) NOT NULL, PRIMARY KEY (id) );"; require_once(ABSPATH . 'wp-admin/upgrade-functions.php'); dbDelta($sql); update_option('addressbook_version', $addressbook_version); } function addressbook_getselect($name) { global $wpdb; $out = ""; return $out; } add_filter('the_content', 'addressbook_list'); function addressbook_list($content) { global $wpdb; $sql = "SELECT * FROM ".$wpdb->prefix."addressbook ORDER BY first_name"; $results = $wpdb->get_results($sql); $out = "
    "; foreach ($results as $row) { $out .= "
  1. \n". " ".$row->first_name." ".$row->surname."\n". " \n". " ".$row->phone."\n". "
    \n". " ".$row->address_line1."\n"; if ($row->address_line2) $out .= " ".$row->address_line2."\n"; $out .= " ".$row->suburb."\n". " ".$row->postcode."\n". " ".$row->state."\n". " ".$row->country."\n". "
  2. \n\n"; } $out .= "
\n"; return preg_replace("//", $out, $content); } ?>