PHP Developer

Wednesday, 28 September 2016

Codeignetor Code


https://drive.google.com/open?id=0B4i05RJ0-BFRZXhEWTVzWVBHblk

Thursday, 15 September 2016

Wordpress Custom Category Template WIth Custom Pagination

Wordpress Custom Category Template WIth Custom Pagination


1) Create new file for custom taxonomy and upload in wordpress theme taxonomy-(taxonomy-name).php
    Example : Id Taxonomy name is "vacancies_uts". Then file name is "taxonomy-vacancies_uts.php".


2) Add this code in functions.php file for pagination anywhere in website

 
<?php
/************ Pagination Function START *************/
function wp_pagination() {
    global $wp_query;
    $big = 12345678;
    $page_format = paginate_links( array(
        'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
        'format' => '?paged=%#%',
        'current' => max( 1, get_query_var('paged') ),
        'total' => $wp_query->max_num_pages,
        'type'  => 'array'
    ) );
    if( is_array($page_format) ) {
        $paged = ( get_query_var('paged') == 0 ) ? 1 : get_query_var('paged');
        echo '<div><ul>';
        echo '<li><span>'. $paged . ' of ' . $wp_query->max_num_pages .'</span></li>';
        foreach ( $page_format as $page ) {
                echo "<li>$page</li>";
        }
       echo '</ul></div>';
    }
}
/************ Pagination Function END *************/
?>
   
3) Add below code in "taxonomy-vacancies_uts.php" and upload in activated theme.

<?php
/**
 * The template for displaying all pages.
 *
*/


get_header(); ?>
<?php

$queried_object = get_queried_object();
$term_id = $queried_object->term_id;
$term_name = $queried_object->name;
?>
<div id="content" class="content" role="main">

<?php
$today = date('m/d/Y');
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;

query_posts(array(
//'posts_per_page' => 2,
'post_type' => 'vacancies', //Post Type
'post_status' => 'publish', //Post Status
'tax_query' => array(
    array(
        'taxonomy' => 'vacancies_uts', //Texonomy Name
        'field' => 'id',
        'terms' => $term_id
    )
),
'meta_query' => array(
    array(
        'key' => 'last_date',  //Meta Field name for compare
        'value' => $today,     //Meta Field Value compare with this value
        'compare' => '>='
    )
),
'paged' => $paged
)
);
?>
<?php if ( have_posts() ) : ?>
<div class="cat_heading"><div class="cat_name"><?php echo $term_name;?></div></div>
<table class="vacancies_tables">
<?php while ( have_posts() ) : the_post(); ?>
    <?php $vacancies_elgible = get_the_terms( get_the_ID(), 'vacancies_elgible' );?>
    <tr>
        <td class="vac_title" data-label="Exam"><a href="<?php echo get_the_permalink();?>"><?php echo get_the_title();?></a></td>
        <td class="detail_link" data-label="Details"><a class="home_viewmore" href="<?php echo get_the_permalink();?>">View More</a></td>
    </tr>
<?php endwhile; ?>
</table>
<div class="custom_pagination"><?php wp_pagination(); ?></div>
<?php else : ?>

<?php //get_template_part( 'no-results', 'page' ); ?>
<?php echo "Sorry, no vacancies available under this Category."; ?>

<?php endif;?>

</div><!-- #content -->

<?php get_footer(); ?>

Tuesday, 13 September 2016

Image Mapping


Image Mapping means more than one link add on single image on different image locations.

And best website for image mapping is https://www.image-map.net/

Thursday, 25 August 2016

Genarate Shortcode and pass values in variables

Genarate Shortcode and pass values in variables :


<?php
/****** Shortcode to get values of any texonomy START ***********/
function custom_cat_shortcode( $attrs ) {
    $output_list = '';
    $category_attrs = shortcode_atts( array(
        'number_of_column' => '1', //default value
        'texonomy_name' => 'vacancies_states', //default value
    ), $attrs );
   
    $number_of_column = $category_attrs[ 'number_of_column' ];
    $texonomy_name = $category_attrs[ 'texonomy_name' ];   
   
    $output_list .= "<strong>Number of Column = </strong>".$number_of_column;
    $output_list .= "<br>";
    $output_list .= "<strong>Texonomy Name = </strong>".$texonomy_name;

    return $output_list;   
}
add_shortcode( 'custom-cat-list', 'custom_cat_shortcode' );
//[custom-cat-list number_of_column="2" texonomy_name="vacancies_uts"] pass values and use this shortcode
// Output is :
//Number of Column = 2
//Texonomy Name = $texonomy_name

?>

How wp_editor and date picker use in Posts Meta Fields(Custom Fields)

How wp_editor and date picker use in Posts Meta Fields(Custom Fields) :


<?php
/*----------- Create Metabox in Custom Post vacancies Code Start ---------------*/

function myplugin_add_custom_box() {
    $screens = array( 'vacancies' );  // Post Type
    foreach ( $screens as $screen ) {
        add_meta_box(
            'myplugin_sectionid',
            __( 'Other Detail', 'myplugin_textdomain' ),
            'myplugin_inner_custom_box',
            $screen
        );
    }
}
add_action( 'add_meta_boxes', 'myplugin_add_custom_box' );

function myplugin_inner_custom_box( $post ) {
  wp_nonce_field( 'myplugin_inner_custom_box', 'myplugin_inner_custom_box_nonce' );
 
  $job_title = get_post_meta( $post->ID, 'job_title', true );
  $opening_date = get_post_meta( $post->ID, 'opening_date', true );
  $last_date = get_post_meta( $post->ID, 'last_date', true );
 
  $pay_scale_desc = get_post_meta( $post->ID, 'pay_scale_desc', false );
 
  ?>
  <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
  <script src="https://code.jquery.com/ui/1.12.0/jquery-ui.js"></script>
  <link rel="stylesheet" href="//code.jquery.com/ui/1.12.0/themes/base/jquery-ui.css">
  <script>
  $( function() {
    $( ".datepicker" ).datepicker();
  } );
  </script>
  <?php
  echo '<table>';
  echo '<tr>';
  echo '<td><label for="myplugin_new_field">';
       _e( "Job Title", 'myplugin_textdomain' );
  echo '</label> </td>';
  echo '<td><input type="text" id="job_title" name="job_title" value="' . esc_attr( $job_title ) . '" size="25" /></td>';
  echo '</tr><tr>';
  echo '<td><label for="myplugin_new_field">';
       _e( "Opening Date", 'myplugin_textdomain' );
  echo '</label> </td>';
  echo '<td><input type="text" class="datepicker" id="opening_date" name="opening_date" value="' . esc_attr( $opening_date ) . '" size="25" /></td>';
  echo '</tr><tr>';
  echo '<td><label for="myplugin_new_field">';
       _e( "Closing Date", 'myplugin_textdomain' );
  echo '</label> </td>';
  echo '<td><input type="text" class="datepicker" id="last_date" name="last_date" value="' . esc_attr( $last_date ) . '" size="25" /></td>';
  echo '</tr>';
  echo '<tr>';
  echo '<td><label for="myplugin_new_field">';
       _e( "Pay Scale Description", 'myplugin_textdomain' );
  echo '</label> </td>';
  echo '<td>';
  wp_editor( $pay_scale_desc[0], 'pay_scale_desc' );
  echo '</td>';
  echo '</tr>';
  echo '</table>';
}
function myplugin_save_postdata( $post_id ) {
  if ( ! isset( $_POST['myplugin_inner_custom_box_nonce'] ) )
    return $post_id;
  $nonce = $_POST['myplugin_inner_custom_box_nonce'];
  if ( ! wp_verify_nonce( $nonce, 'myplugin_inner_custom_box' ) )
      return $post_id;
  if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
      return $post_id;
  if ( 'page' == $_POST['post_type'] ) {
    if ( ! current_user_can( 'edit_page', $post_id ) )
        return $post_id;
  } else {
    if ( ! current_user_can( 'edit_post', $post_id ) )
        return $post_id;
  }
 
  $job_title = sanitize_text_field( $_POST['job_title'] );
  $opening_date = sanitize_text_field( $_POST['opening_date'] );
  $last_date = sanitize_text_field( $_POST['last_date'] );
 
  update_post_meta( $post_id, 'job_title', $job_title );
  update_post_meta( $post_id, 'opening_date', $opening_date );
  update_post_meta( $post_id, 'last_date', $last_date );
 
  if ( isset ( $_POST['pay_scale_desc'] ) ) {
    update_post_meta( $post_id, 'pay_scale_desc', $_POST['pay_scale_desc'] );
  }
}
add_action( 'save_post', 'myplugin_save_postdata' );

/*----------- Create Metabox in Custom Post vacancies Code END ---------------*/
?>

 =========================================================

And How wp_editor value get in Frontend in same Format :


<?php 
$pay_scale_desc = get_post_meta( $post->ID, 'pay_scale_desc', false );
echo "<pre>";
print_r($pay_scale_desc[0]);
echo "</pre>";
?>

Friday, 19 August 2016

Custom Login Form in Wordpress

Custom Login Form in Wordpress :


<?php

/*
  Plugin Name: Custom Login Form
  Plugin URI:
  Description: Simple Login form plugin that just work, customize easily in code and set redirection or condition according to need.
  Version: 1.0.0
  Author: Sunil Sharma
  Author URI:
 */


function dlf_form() {
?>
<form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
    <div class="login-form">
        <h5>Your Username or Email</h5>
        <div class="form-group">
            <input name="login_name" type="text" class="form-control login-field" value="" placeholder="Enter Username or Email" id="login-name" />
            <label class="login-field-icon fui-user" for="login-name"></label>
        </div>
       
        <h5>Your Password</h5>
        <div class="form-group">
            <input  name="login_password" type="password" class="form-control login-field" value="" placeholder="Password" id="login-pass" />
            <label class="login-field-icon fui-lock" for="login-pass"></label>
        </div>
       
        <?php if(isset($_GET["value"]) && $_GET["value"] != "") { ?>
            <input type="hidden" value="<?php echo $_GET["value"];?>" name="service_redirect">
        <?php } ?>
       
        <div class="form-group">
            <input name="rememberme" type="checkbox" id="lwa_rememberme" value="forever" /> <label ><?php _e( 'Remember Me', 'funding' ) ?></label>
        </div>
        <input class="btn btn-primary btn-lg btn-block" type="submit"  name="dlf_submit" value="SIGN IN TO BACKYOURCAUSE" />
    </div>
</form>

<?php
}

function dlf_auth( $username, $password, $service_red ) {
global $user;
$creds = array();

$user = get_user_by('email',$username);
if(!empty($user->user_login)){
    $username = $user->user_login;
}
$creds['user_login'] = $username;
$creds['user_password'] =  $password;
$creds['service_redirect'] =  $service_red;
$creds['user_status'] =  0;
$creds['remember'] = true;
$user = wp_signon( $creds, false );
if ( is_wp_error($user) ) {
echo $user->get_error_message();
}
if ( !is_wp_error($user) ) {
    $user_id = $user->data->ID;
    $user_query = "SELECT `user_status` FROM `wp_users` WHERE `ID` = '".$user_id."'";
    $user_run = mysql_query($user_query);
    $user_value = mysql_fetch_object($user_run);
    $user_status = $user_value->user_status;

    $user_role = $user->roles[0];
   
    if($user_status == 1){
        wp_logout();
        $newURL = site_url()."/sign-in/?msg=Please Confirm your email id";
        header('Location: '.$newURL);
    } else {
        if($creds['service_redirect'] != ""){
            $newURL = $creds['service_redirect'];
            header('Location: '.$newURL);
        } else {
            if($user_role == "administrator"){
                $newURL = site_url()."/wp-admin";
                header('Location: '.$newURL);
            }
            if($user_role == "business"){
                $newURL = site_url()."/business-profile";
                header('Location: '.$newURL);
            }
            if($user_role == "subscriber"){
                $newURL = site_url()."/my-profile";
                header('Location: '.$newURL);
            }
        }
       
    }
}
}

function dlf_process() {
    if (isset($_POST['dlf_submit'])) {
        dlf_auth($_POST['login_name'], $_POST['login_password'], $_POST['service_redirect']);
    }
    dlf_form();
}

function dlf_shortcode() {
    ob_start();
    dlf_process();
    return ob_get_clean();
}

add_shortcode('dm_login_form', 'dlf_shortcode');

//[dm_login_form] use this shortcode to show login form in front end
?>

How Featured Image Assign and upload for Post(By Post ID)

How Featured Image Assign and upload for Post(By Post ID):

<?php
$post_id = $post_id; //post id for which featured image upload
$uploaddir = wp_upload_dir();
$selected_postImage = $_FILES["files"]["name"];
$project_postImage = $uploaddir['path'] . '/' . $selected_postImage;
if ($selected_postImage != '') {
    $filename   = basename($project_postImage);
    $wp_filetype = wp_check_filetype( $project_postImage, null );
    $attachment = array(
         'post_mime_type' => $wp_filetype['type'],
         'post_title'     => sanitize_file_name( $filename ),
         'post_content'   => '',
         'post_status'    => 'inherit'
    );
    $attach_id = wp_insert_attachment( $attachment, $project_postImage, $post_id );
   
    require_once(ABSPATH . 'wp-admin/includes/image.php');
   
    $uploadfile = $uploaddir['path'] . '/' . $filename;
    move_uploaded_file( $_FILES['files']['tmp_name'] , $uploadfile );
    $attach_data = wp_generate_attachment_metadata( $attach_id, $project_postImage );
    wp_update_attachment_metadata( $attach_id, $attach_data );
    set_post_thumbnail( $post_id, $attach_id );
}
?>

Tuesday, 3 May 2016

How to create category from frontend in Wordpress



How to create category from frontend in Wordpress (Also for custom taxonomy)


<?php
$custom_texonmy = 'services_categories';   // Custom texonomy type slug
$job_category = 'Access Covers & Gratings';  //Category name
$cat = get_term_by('name',htmlspecialchars($job_category),'services_categories');  //get category by name
if($cat){
    //This code run id category with above name already exist
    $cat_ID = $cat->term_id; //term_id of category
    $job_type = $cat->slug; //Slug of category
}

if($cat_ID == 0) {
    //This code run id category with above name not exist and create new category
    $cat_name = $job_category;
    $cat_insert = wp_insert_term(
        $cat_name,
        $custom_texonmy
    );
    $cat_ID = $cat_insert['term_id'];
    if($cat_ID != 0){
        $new_cat = get_term_by( 'term_id', $cat_ID, $custom_texonmy );
        if($new_cat){
            $job_type = $new_cat->slug;
        }
    }
} else {
    $cat_ID;
    $job_type = $job_type;
}

?>

How to assign category or “custom taxonomy” category to post from front end



How to assign category or “custom taxonomy” category to post from front end


<?php
$custom_texonmy = 'services_categories';  // Custom texonomy type slug
$job_category = 'Access Covers & Gratings';  //Category name
$post_id = $post_id; //Post id for which assign above category
$cat = get_term_by('name',htmlspecialchars($job_category),$custom_texonmy);  //get category by name
if($cat){
    $cat_ID = $cat->term_id;  // term_id of category
    $job_type = $cat->slug;  //Slug of category
}
if ($job_type) {
    $services_categories = wp_set_object_terms($post_id, $job_type, $custom_texonmy );  //This code assign category of custom texonomy to post from front end
}

?>

Thursday, 31 March 2016

WordPress Post Custom Pagination Without Plugin

WordPress Post Custom Pagination Without Plugin

This code helps you to create template and get post with pagination without using plugin.

<?php

/*

Template Name: Post Pagination without Plugin in WordPress

*/
get_header();
?>
<?php
global $wp_query;
$big = 999999999; // need an unlikely integer
echo paginate_links( array(
        'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
        'format' => '?paged=%#%',
        'current' => max( 1, get_query_var('paged') ),
        'total' => $wp_query->max_num_pages
) );
?>
<?php
function wp_pagination() {
global $wp_query;
$big = 12345678;
$page_format = paginate_links( array(
    'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
    'format' => '?paged=%#%',
    'current' => max( 1, get_query_var('paged') ),
    'total' => $wp_query->max_num_pages,
    'type'  => 'array'
) );
if( is_array($page_format) ) {
            $paged = ( get_query_var('paged') == 0 ) ? 1 : get_query_var('paged');
            echo '<div><ul>';
            echo '<li><span>'. $paged . ' of ' . $wp_query->max_num_pages .'</span></li>';
            foreach ( $page_format as $page ) {
                    echo "<li>$page</li>";
            }
           echo '</ul></div>';
}
}
?>

<article id="core_middle_column" class="col-md-8 col-sm-8"><div id="core_ajax_callback"></div>
<div class="clearfix" id="recentlistings">
<?php 

$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;

query_posts(array( 'posts_per_page' => 2, 'post_type' => 'post', 'post_status' => 'publish', 'post__in' => array(1, 2, 3, 4), 'paged' => $paged ));

if ( have_posts() ) : ?>
<div class="_searchresultsdata">
<div class="panel panel-default">
<div class="list_style  wlt_search_results row">
<?php while ( have_posts() ) : the_post(); ?>
<div class="itemdata col-md-4 item-121 col-sm-6 col-xs-12">
<div class="thumbnail clearfix">
<?php echo get_the_title();?>
</div>
</div>
<?php endwhile; ?>
</div>
</div>
</div>
<div class="custom_pagination"><?php wp_pagination(); ?></div>
<?php else : ?>
<?php // no posts found message goes here ?>
<?php endif; ?>
</div>
</article>
<style>
.custom_pagination ul {
  display: initial;
}

.custom_pagination li:first-child{
 background-color: #fff;
  border: 1px solid #ddd;
  color: #0b5b96;
  list-style: outside none none !important;
  padding: 6px 12px !important;
  text-decoration: none;
  border-radius:15px;
  float:right !important;
}

.custom_pagination li {
  float: left !important;
  list-style: outside none none !important;
}

.custom_pagination .page-numbers {
  background-color: #fff;
  border: 1px solid #ddd;
  color: #0b5b96;
 list-style: outside none none !important;
  padding: 6px 12px !important;
  text-decoration: none;
float: left;
}

.page-numbers.current {
  background-color: #0b5b96 !important;
  color: #fff !important;

}
</style>
<?php
get_footer();
?>

Monday, 28 March 2016

Add and Removes a Capability for a User Role in Wordpress

Add and Removes a Capability for a User Role in Wordpress

Add this code in function.php to Add and Removes a Capability from a User Role

<?php
/**
 * Remove capabilities from editors.
 *
 * Call the function when your plugin/theme is activated.
 */

function wpcodex_set_capabilities() {

    // Get the role object.
    $editor = get_role( 'editor' ); // Get alredy registerd Role "Editor" in wordpress

    // A list of capabilities to remove from editors.
    $caps_remove = array(
        'moderate_comments',
        'manage_categories',  // Allows user to manage post categories
        'manage_links',  // Allows user to edit links
        'edit_others_posts',  // Allows user to edit others posts not just their own
        'edit_others_pages',  // Allows user to edit pages
        'delete_posts',  //  Allows user to delete posts
        'edit_themes', // false denies this capability. User can’t edit your theme
        'install_plugins', // User cant add new plugins
        'update_plugin', // User can’t update any plugins
        'update_core', // user cant perform core updates
    );
   
    // A list of capabilities to Add for editors.
    $caps_add = array(
        'read', // true allows this capability
        'edit_posts', // Allows user to edit their own posts
        'edit_pages', // Allows user to edit pages
        'edit_others_posts', // Allows user to edit others posts not just their own
        'create_posts', // Allows user to create new posts
        'manage_categories', // Allows user to manage post categories
        'publish_posts', // Allows the user to publish, otherwise posts stays in draft mode
    );

    foreach ( $caps_remove as $cap ) {
        // Remove the capability.
        $editor->remove_cap( $cap );
    }
   
    foreach ( $caps_add as $capd ) {
        // Add the capability.
        $editor->add_cap( $capd );
    }
}
add_action( 'init', 'wpcodex_set_capabilities' );

?>

Create New User Role With Capability in Wordpress

Create New User Role With Capability in Wordpress


Add below code in function.php, then new role "Client" is registered with capabilities .

<?php
$result = add_role( 'client', __(

'Client' ),

array(

'read' => true, // true allows this capability
'edit_posts' => true, // Allows user to edit their own posts
'edit_pages' => true, // Allows user to edit pages
'edit_others_posts' => true, // Allows user to edit others posts not just their own
'create_posts' => true, // Allows user to create new posts
'manage_categories' => true, // Allows user to manage post categories
'publish_posts' => true, // Allows the user to publish, otherwise posts stays in draft mode
'edit_themes' => false, // false denies this capability. User can’t edit your theme
'install_plugins' => false, // User cant add new plugins
'update_plugin' => false, // User can’t update any plugins
'update_core' => false // user cant perform core updates

)

);

?>

Saturday, 27 February 2016

Custom Pagination Code For Wordpress, PHP with MySql

Custom Pagination Code For Wordpress, PHP with MySql


Pagination in php with custom query


<?php
/**
 * Template Name: Downloded Files Page
 *
 * @package WordPress
 * @subpackage Twenty_Fourteen
 * @since Twenty Fourteen 1.0
 */


get_header(); ?>
<?php
function paginate($reload, $page, $tpages) {
    $adjacents = 2;
    $prevlabel = "&lsaquo; Prev";
    $nextlabel = "Next &rsaquo;";
    $out = "";
    // previous
    if ($page == 1) {
        $out.= "<span>" . $prevlabel . "</span>\n";
    } elseif ($page == 2) {
        $out.= "<li><a  href=\"" . $reload . "\">" . $prevlabel . "</a>\n</li>";
    } else {
        $out.= "<li><a  href=\"" . $reload . "&amp;pageno=" . ($page - 1) . "\">" . $prevlabel . "</a>\n</li>";
    }
 
    $pmin = ($page > $adjacents) ? ($page - $adjacents) : 1;
    $pmax = ($page < ($tpages - $adjacents)) ? ($page + $adjacents) : $tpages;
    for ($i = $pmin; $i <= $pmax; $i++) {
        if ($i == $page) {
            $out.= "<li  class=\"active\"><a href=''>" . $i . "</a></li>\n";
        } elseif ($i == 1) {
            $out.= "<li><a  href=\"" . $reload . "\">" . $i . "</a>\n</li>";
        } else {
            $out.= "<li><a  href=\"" . $reload . "&amp;pageno=" . $i . "\">" . $i . "</a>\n</li>";
        }
    }
   
    if ($page < ($tpages - $adjacents)) {
        $out.= "<li><a style='font-size:11px' href=\"" . $reload . "&amp;pageno=" . $tpages . "\">" . $tpages . "</a>\n</li>";
    }
    // next
    if ($page < $tpages) {
        $out.= "<li><a  href=\"" . $reload . "&amp;pageno=" . ($page + 1) . "\">" . $nextlabel . "</a>\n</li>";
    } else {
        $out.= "<span style='font-size:11px'>" . $nextlabel . "</span>\n";
    }
    $out.= "";
    return $out;
}

$per_page = 2;         // number of results to show per page
$result = mysql_query("SELECT * FROM wp_uploads");
$total_results = mysql_num_rows($result);
$total_pages = ceil($total_results / $per_page);//total pages we going to have

//-------------if page is setcheck------------------//
if (isset($_GET['pageno'])) {
    $show_page = $_GET['pageno'];             //it will telles the current page
    if ($show_page > 0 && $show_page <= $total_pages) {
        $start = ($show_page - 1) * $per_page;
        $end = $start + $per_page;
    } else {
        // error - show first set of results
        $start = 0;             
        $end = $per_page;
    }
} else {
    // if page isn't set, show first set of results
    $start = 0;
    $end = $per_page;
}
// display pagination
$page = intval($_GET['pageno']);

$tpages=$total_pages;
if ($page <= 0)
    $page = 1;
?>

<div id="main-content" class="main-content">
    <div class="container">
        <div id="primary" class="content-area">
            <div id="content" class="site-content" role="main">
                <div class="row">
                    <h2 class="upload_front_head">Uploaded File List</h2>
                    <div class="first_div" style="text-align:center;">
                        <div class="div_heading">
                            <!--<div class="heading_div">S.No.</div>-->
                            <div class="heading_div">Ttile</div>
                            <div class="heading_div">File Name</div>
                        </div>
                        <?php
                        $n= 0;
                        // loop through results of database query, displaying them in the table
                        for ($i = $start; $i < $end; $i++) {
                            $n = $n + 1;
                            // make sure that PHP doesn't try to show results that don't exist
                            if ($i == $total_results) {
                                break;
                            }
                         
                            // echo out the contents of each row into a table
                           
                            echo "<div class='content_row'>";
                                //echo "<div class='content_data'><strong>".$n.".<strong></div>";
                               
                                echo "<div class='content_data'>".mysql_result($result, $i, 'title')."</div>";
                               
                                echo "<div class='content_data'>".mysql_result($result, $i, 'origional_file')."</div>";
                               
                            echo "</div>";
                        } 
                        ?>

                    </div>
                   
                    <div class="pagination_section">
                        <?php
                        $reload = get_page_link() . "?tpages=" . $tpages;
                        echo '<div class="pagination"><ul>';
                        if ($total_pages > 1) {
                            echo paginate($reload, $show_page, $total_pages);
                        }
                        echo "</ul></div>";
                        // pagination
                        ?>
                    </div>
                </div>
            </div><!-- #content -->
        </div><!-- #primary -->
    </div>
</div><!-- #main-content -->
<style>
.pagination_section {
  float: left;
  margin-top: 10px;
  text-align: center;
  width: 100%;
}
.pagination {
  height: 40px;
  margin: 20px 0;
}
.pagination ul {
  border-radius: 3px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  display: inline-block;
  margin-bottom: 0;
  margin-left: 0;
}
.pagination ul li {
  display: inline;
}
.pagination li:first-child a, .pagination li:first-child span, .pagination li a {
  border-left-width: 1px;
  border-radius: 3px 0 0 3px;
  color: #3281ae;
  font-weight: 800;
}
.pagination a, .pagination span {
  -moz-border-bottom-colors: none;
  -moz-border-left-colors: none;
  -moz-border-right-colors: none;
  -moz-border-top-colors: none;
  background-color: #fff;
  border-color: #ddd;
  border-image: none;
  border-style: solid;
  border-width: 1px 1px 1px 0;
  float: left;
  line-height: 38px;
  padding: 0 14px;
  text-decoration: none;
}
.pagination .active a, .pagination .active span {
  color: #999;
  cursor: default;
}
.pagination a:hover, .pagination .active a, .pagination .active span {
  background-color: #f5f5f5;
}
</style>

<?php
get_footer();
?>