[insert_php]
define(‘PATH_TO_PLUGIN_DIR’, plugins_url(”, __FILE__));
echo ‘‘;
echo ‘‘;
echo ‘‘;
echo ‘‘;
$id = $_GET[‘id’];
$id_post = get_the_ID();
print’‘;
echo ‘

From   To   Itemtype   Theme   Subject  
         

‘;

if(isset($_POST[‘submit’])) {
//print_r($_POST);
global $wpdb;
$from_date = $_POST[‘from_date’];
$to_date = $_POST[‘to_date’];
$itemtype_search = $_POST[‘iteamtype’];
$subject_search = $_POST[‘subject’];
$theme_search = $_POST[‘theme’];
if(!empty($from_date) && !empty($to_date) && !empty($itemtype_search) && !empty($subject_search) && !empty($theme_search)){
$pagenum = isset( $_GET[‘pagenum’] ) ? absint( $_GET[‘pagenum’] ) : 1;
$limit = 5; // number of rows in page
$offset = ( $pagenum – 1 ) * $limit;
$total = $wpdb->get_var( “select * from wp_news where date BETWEEN ‘”.$from_date.”‘ AND ‘”.$to_date.”‘ AND item_type LIKE ‘%”.$itemtype_search.”%’ AND subject LIKE ‘%”.$subject_search.”%’ AND theme LIKE ‘%”.$theme_search.”%'” );
$num_of_pages = ceil( $total / $limit );

$results = $wpdb->get_results(“select * from wp_news where date BETWEEN ‘”.$from_date.”‘ AND ‘”.$to_date.”‘ AND item_type LIKE ‘%”.$itemtype_search.”%’ AND subject LIKE ‘%”.$subject_search.”%’ AND theme LIKE ‘%”.$theme_search.”%’ order by date desc LIMIT $offset, $limit”,ARRAY_A);
}else if(!empty($from_date) && !empty($to_date) && !empty($itemtype_search) && !empty($subject_search) && empty($theme_search)){
$pagenum = isset( $_GET[‘pagenum’] ) ? absint( $_GET[‘pagenum’] ) : 1;
global $wpdb;
$limit = 5; // number of rows in page
$offset = ( $pagenum – 1 ) * $limit;
$total = $wpdb->get_var( “select * from wp_news where date BETWEEN ‘”.$from_date.”‘ AND ‘”.$to_date.”‘ AND item_type LIKE ‘%”.$itemtype_search.”%’ AND subject LIKE ‘%”.$subject_search.”%'” );
$num_of_pages = ceil( $total / $limit );

$results = $wpdb->get_results(“select * from wp_news where date BETWEEN ‘”.$from_date.”‘ AND ‘”.$to_date.”‘ AND item_type LIKE ‘%”.$itemtype_search.”%’ AND subject LIKE ‘%”.$subject_search.”%’ order by date desc LIMIT $offset, $limit”,ARRAY_A);
}else if(!empty($from_date) && !empty($to_date) && !empty($itemtype_search) && empty($subject_search) && !empty($theme_search)){
$pagenum = isset( $_GET[‘pagenum’] ) ? absint( $_GET[‘pagenum’] ) : 1;
global $wpdb;
$limit = 5; // number of rows in page
$offset = ( $pagenum – 1 ) * $limit;
$total = $wpdb->get_var( “select * from wp_news where date BETWEEN ‘”.$from_date.”‘ AND ‘”.$to_date.”‘ AND item_type LIKE ‘%”.$itemtype_search.”%’ AND theme LIKE ‘%”.$theme_search.”%'” );
$num_of_pages = ceil( $total / $limit );

$results = $wpdb->get_results(“select * from wp_news where date BETWEEN ‘”.$from_date.”‘ AND ‘”.$to_date.”‘ AND item_type LIKE ‘%”.$itemtype_search.”%’ AND theme LIKE ‘%”.$theme_search.”%’ order by date desc LIMIT $offset, $limit”,ARRAY_A);
}else if(!empty($from_date) && !empty($to_date) && empty($itemtype_search) && !empty($subject_search) && !empty($theme_search)){
$pagenum = isset( $_GET[‘pagenum’] ) ? absint( $_GET[‘pagenum’] ) : 1;
global $wpdb;
$limit = 5; // number of rows in page
$offset = ( $pagenum – 1 ) * $limit;
$total = $wpdb->get_var( “select * from wp_news where date BETWEEN ‘”.$from_date.”‘ AND ‘”.$to_date.”‘ AND subject LIKE ‘%”.$subject_search.”%’ AND theme LIKE ‘%”.$theme_search.”%'” );
$num_of_pages = ceil( $total / $limit );

$results = $wpdb->get_results(“select * from wp_news where date BETWEEN ‘”.$from_date.”‘ AND ‘”.$to_date.”‘ AND subject LIKE ‘%”.$subject_search.”%’ AND theme LIKE ‘%”.$theme_search.”%’ order by date desc LIMIT $offset, $limit”,ARRAY_A);
}else if(empty($from_date) && empty($to_date) && !empty($itemtype_search) && !empty($subject_search) && !empty($theme_search)){
$pagenum = isset( $_GET[‘pagenum’] ) ? absint( $_GET[‘pagenum’] ) : 1;
global $wpdb;
$limit = 5; // number of rows in page
$offset = ( $pagenum – 1 ) * $limit;
$total = $wpdb->get_var( “select * from wp_news where item_type LIKE ‘%”.$itemtype_search.”%’ AND subject LIKE ‘%”.$subject_search.”%’ AND theme LIKE ‘%”.$theme_search.”%'” );
$num_of_pages = ceil( $total / $limit );

$results = $wpdb->get_results(“select * from wp_news where item_type LIKE ‘%”.$itemtype_search.”%’ AND subject LIKE ‘%”.$subject_search.”%’ AND theme LIKE ‘%”.$theme_search.”%’ order by date desc LIMIT $offset, $limit”,ARRAY_A);
}else if(!empty($from_date) && !empty($to_date) && !empty($itemtype_search) && empty($subject_search) && empty($theme_search)){
$pagenum = isset( $_GET[‘pagenum’] ) ? absint( $_GET[‘pagenum’] ) : 1;
global $wpdb;
$limit = 5; // number of rows in page
$offset = ( $pagenum – 1 ) * $limit;
$total = $wpdb->get_var( “select * from wp_news where date BETWEEN ‘”.$from_date.”‘ AND ‘”.$to_date.”‘ AND item_type LIKE ‘%”.$itemtype_search.”%'” );
$num_of_pages = ceil( $total / $limit );

$results = $wpdb->get_results(“select * from wp_news where date BETWEEN ‘”.$from_date.”‘ AND ‘”.$to_date.”‘ AND item_type LIKE ‘%”.$itemtype_search.”%’ order by date desc LIMIT $offset, $limit”,ARRAY_A);
}else if(!empty($from_date) && !empty($to_date) && empty($itemtype_search) && !empty($subject_search) && empty($theme_search)){
$pagenum = isset( $_GET[‘pagenum’] ) ? absint( $_GET[‘pagenum’] ) : 1;
global $wpdb;
$limit = 5; // number of rows in page
$offset = ( $pagenum – 1 ) * $limit;
$total = $wpdb->get_var( “select * from wp_news where date BETWEEN ‘”.$from_date.”‘ AND ‘”.$to_date.”‘ AND subject LIKE ‘%”.$subject_search.”%'” );
$num_of_pages = ceil( $total / $limit );

$results = $wpdb->get_results(“select * from wp_news where date BETWEEN ‘”.$from_date.”‘ AND ‘”.$to_date.”‘ AND subject LIKE ‘%”.$subject_search.”%’ order by date desc LIMIT $offset, $limit”,ARRAY_A);
}else if(!empty($from_date) && !empty($to_date) && empty($itemtype_search) && empty($subject_search) && !empty($theme_search)){
$pagenum = isset( $_GET[‘pagenum’] ) ? absint( $_GET[‘pagenum’] ) : 1;
global $wpdb;
$limit = 5; // number of rows in page
$offset = ( $pagenum – 1 ) * $limit;
$total = $wpdb->get_var( “select * from wp_news where date BETWEEN ‘”.$from_date.”‘ AND ‘”.$to_date.”‘ AND theme LIKE ‘%”.$theme_search.”%'” );
$num_of_pages = ceil( $total / $limit );

$results = $wpdb->get_results(“select * from wp_news where date BETWEEN ‘”.$from_date.”‘ AND ‘”.$to_date.”‘ AND theme LIKE ‘%”.$theme_search.”%’ order by date desc LIMIT $offset, $limit”,ARRAY_A);
}else if(empty($from_date) && empty($to_date) && !empty($itemtype_search) && !empty($subject_search) && empty($theme_search)){
$pagenum = isset( $_GET[‘pagenum’] ) ? absint( $_GET[‘pagenum’] ) : 1;
global $wpdb;
$limit = 5; // number of rows in page
$offset = ( $pagenum – 1 ) * $limit;
$total = $wpdb->get_var( “select * from wp_news where item_type LIKE ‘%”.$itemtype_search.”%’ AND subject LIKE ‘%”.$subject_search.”%'” );
$num_of_pages = ceil( $total / $limit );

$results = $wpdb->get_results(“select * from wp_news where item_type LIKE ‘%”.$itemtype_search.”%’ AND subject LIKE ‘%”.$subject_search.”%’ order by date desc LIMIT $offset, $limit”,ARRAY_A);
}else if(empty($from_date) && empty($to_date) && !empty($itemtype_search) && empty($subject_search) && !empty($theme_search)){
$pagenum = isset( $_GET[‘pagenum’] ) ? absint( $_GET[‘pagenum’] ) : 1;
global $wpdb;
$limit = 5; // number of rows in page
$offset = ( $pagenum – 1 ) * $limit;
$total = $wpdb->get_var( “select * from wp_news where item_type LIKE ‘%”.$itemtype_search.”%’ AND theme LIKE ‘%”.$theme_search.”%'” );
$num_of_pages = ceil( $total / $limit );

$results = $wpdb->get_results(“select * from wp_news where item_type LIKE ‘%”.$itemtype_search.”%’ AND theme LIKE ‘%”.$theme_search.”%’ order by date desc LIMIT $offset, $limit”,ARRAY_A);
}else if(empty($from_date) && empty($to_date) && empty($itemtype_search) && !empty($subject_search) && !empty($theme_search)){
$pagenum = isset( $_GET[‘pagenum’] ) ? absint( $_GET[‘pagenum’] ) : 1;
global $wpdb;
$limit = 5; // number of rows in page
$offset = ( $pagenum – 1 ) * $limit;
$total = $wpdb->get_var( “select * from wp_news where subject LIKE ‘%”.$subject_search.”%’ AND theme LIKE ‘%”.$theme_search.”%'” );
$num_of_pages = ceil( $total / $limit );

$results = $wpdb->get_results(“select * from wp_news where subject LIKE ‘%”.$subject_search.”%’ AND theme LIKE ‘%”.$theme_search.”%’ order by date desc LIMIT $offset, $limit”,ARRAY_A);
}if(!empty($from_date) && !empty($to_date) && empty($itemtype_search) && empty($subject_search) && empty($theme_search)){
$pagenum = isset( $_GET[‘pagenum’] ) ? absint( $_GET[‘pagenum’] ) : 1;
global $wpdb;
$limit = 5; // number of rows in page
$offset = ( $pagenum – 1 ) * $limit;
$total = $wpdb->get_var( “select * from wp_news where date BETWEEN ‘”.$from_date.”‘ AND ‘”.$to_date.”‘” );
$num_of_pages = ceil( $total / $limit );

$results = $wpdb->get_results(“select * from wp_news where date BETWEEN ‘”.$from_date.”‘ AND ‘”.$to_date.”‘ order by date desc LIMIT $offset, $limit”,ARRAY_A);
}else if(empty($from_date) && empty($to_date) && !empty($itemtype_search) && empty($subject_search) && empty($theme_search)){
$pagenum = isset( $_GET[‘pagenum’] ) ? absint( $_GET[‘pagenum’] ) : 1;
global $wpdb;
$limit = 5; // number of rows in page
$offset = ( $pagenum – 1 ) * $limit;
$total = $wpdb->get_var( “select * from wp_news where item_type LIKE ‘%”.$itemtype_search.”%'” );
$num_of_pages = ceil( $total / $limit );

$results = $wpdb->get_results(“select * from wp_news where item_type LIKE ‘%”.$itemtype_search.”%’ order by date desc LIMIT $offset, $limit”,ARRAY_A);
}if(empty($from_date) && empty($to_date) && empty($itemtype_search) && !empty($subject_search) && empty($theme_search)){
$pagenum = isset( $_GET[‘pagenum’] ) ? absint( $_GET[‘pagenum’] ) : 1;
global $wpdb;
$limit = 5; // number of rows in page
$offset = ( $pagenum – 1 ) * $limit;
$total = $wpdb->get_var( “select * from wp_news where subject LIKE ‘%”.$subject_search.”%'” );
$num_of_pages = ceil( $total / $limit );

$results = $wpdb->get_results(“select * from wp_news where subject LIKE ‘%”.$subject_search.”%’ order by date desc LIMIT $offset, $limit”,ARRAY_A);
}if(empty($from_date) && empty($to_date) && empty($itemtype_search) && empty($subject_search) && !empty($theme_search)){
$pagenum = isset( $_GET[‘pagenum’] ) ? absint( $_GET[‘pagenum’] ) : 1;
global $wpdb;
$limit = 5; // number of rows in page
$offset = ( $pagenum – 1 ) * $limit;
$total = $wpdb->get_var( “select * from wp_news where theme LIKE ‘%”.$theme_search.”%'” );
$num_of_pages = ceil( $total / $limit );

$results = $wpdb->get_results(“select * from wp_news where theme LIKE ‘%”.$theme_search.”%’ order by date desc LIMIT $offset, $limit”,ARRAY_A);
}if(empty($from_date) && empty($to_date) && empty($itemtype_search) && empty($subject_search) && empty($theme_search)){
$pagenum = isset( $_GET[‘pagenum’] ) ? absint( $_GET[‘pagenum’] ) : 1;
global $wpdb;
$limit = 5; // number of rows in page
$offset = ( $pagenum – 1 ) * $limit;
$total = $wpdb->get_var( “SELECT COUNT(`news_id`) FROM wp_news” );
$num_of_pages = ceil( $total / $limit );

$results = $wpdb->get_results(“select * from wp_news order by date desc LIMIT $offset, $limit”,ARRAY_A);
}

//echo “

";
//print_r($results);
//echo "

“;
if(empty($results)){
echo ‘

NO Record Found

‘;
}else{
foreach($results as $news_results) {

$new_date = date(‘F jS, Y’, strtotime($news_results[‘date’]));
echo ‘

‘.stripslashes($news_results[‘caption’]).’

Read Full Story

‘;

}
}
}else{
/*pagination*/
$pagenum = isset( $_GET[‘pagenum’] ) ? absint( $_GET[‘pagenum’] ) : 1;
/*pagination*/
global $wpdb;
/*pagination*/
$limit = 5; // number of rows in page
$offset = ( $pagenum – 1 ) * $limit;
$total = $wpdb->get_var( “SELECT COUNT(`news_id`) FROM wp_news” );
$num_of_pages = ceil( $total / $limit );
/*pagination*/
$results = $wpdb->get_results(“select * from wp_news order by date desc LIMIT $offset, $limit”,ARRAY_A);
//echo “

";
//print_r($results);
//echo "

“;
foreach($results as $news_results) {
$new_date = date(‘F jS, Y’, strtotime($news_results[‘date’]));
echo ‘

‘.stripslashes($news_results[‘caption’]).’

Read Full Story

‘;
}

}

remove_filter( ‘the_content’, ‘wpautop’ );
remove_filter( ‘the_excerpt’, ‘wpautop’ );
/*pagination*/
$page_links = paginate_links( array(‘base’ => add_query_arg( ‘pagenum’, ‘%#%’ ),’format’ => ”,’prev_text’ => __( ‘«’, ‘text-domain’ ),’next_text’ => __( ‘»’, ‘text-domain’ ),’total’ => $num_of_pages,
‘current’ => $pagenum) );

if ( $page_links ) {
echo ‘

‘ . $page_links . ‘

‘;
}
/*pagination*/
[/insert_php]