Last active
December 31, 2015 03:49
-
-
Save eyedol/7930458 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: Find Agents | |
Plugin URI :http://www.olamshs.com | |
Description: Available agents | |
Author: Gideon Makui | |
Version: 1.0 | |
Author URI:http://gidmakus.wordpress.com | |
*/ | |
require_once('inc/wp-config.php'); | |
require_once('inc/wp-load.php'); | |
global $agent_tbl_version; | |
$agent_tbl_version = "1.0"; | |
function agents_install() { | |
global $wpdb; | |
global $agent_tbl_version; | |
$table_name = $wpdb->prefix . "agent2"; | |
$sql = "CREATE TABLE $table_name ( | |
agentid mediumint(9) NOT NULL AUTO_INCREMENT, | |
agent-name varchar(50), | |
company varchar(50) , | |
address varchar(100), | |
contacts VARCHAR(20), | |
town-city varchar(50), | |
UNIQUE KEY agentid (agentid) | |
);"; | |
add_option( "agent_tbl_version", $agent_tbl_version ); | |
register_activation_hook( __FILE__, 'agents_install' ); | |
} | |
function gidz_admin_actions() { | |
add_options_page('Agents','Agents','manage_options',__FILE__,'agents_admin'); | |
} | |
add_action('admin_menu','gidz_admin_actions'); | |
function agents_admin() { | |
?> | |
<div class="wrap"> | |
<h4> These are Agents of listed properties</h4> | |
<table class="widefat"> | |
<thead> | |
<tr> | |
<th>Agent ID</th> | |
<th>Agent Name</th> | |
<th>Company</th> | |
<th>Address</th> | |
<th>Contacts</th> | |
<th>Town-City</th> | |
</tr> | |
</thead> | |
<tfoot> | |
<tr> | |
<th>Agent ID</th> | |
<th>Agent Name</th> | |
<th>Company</th> | |
<th>Address</th> | |
<th>Contacts</th> | |
<th>Town-City</th> | |
</tr> | |
</tfoot> | |
<tbody> | |
<?php | |
global $wpdb; | |
$table = $wpdb->prefix."agents"; | |
$gidz_function = $wpdb->get_results(" | |
SELECT agentid,agent-name,company,address,contacts,town-city FROM $table WHERE agentid = 1"); | |
?> | |
<?php | |
foreach($gidz_function as $agents) | |
{ | |
?> | |
<tr> | |
<?php | |
echo "<td>".$agents->agentid."</td>"; | |
echo "<td>".$agents->agent-name."</td>"; | |
echo "<td>".$agents->company."</td>"; | |
echo "<td>".$agents->address."</td>"; | |
echo "<td>".$agents->contacts."</td>"; | |
echo "<td>".$agents->town-city."</td>"; | |
?> | |
</tr> | |
<?php | |
} | |
?> | |
</tbody> | |
</div> | |
<?php | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment