<?php

require_once("db_conn_class2.php");

$blog_id         = 0;
$blog_title      = "";
$blog_desc       = "";
$written_by      = "";
$posting_dt      = "";
$blog_image_path = "";

$blogs = "";

$no_of_blogs = 0;

if(isset($_GET['id']) && !empty($_GET['id'])) {
   $blog_id = $_GET['id'];
}

//creating object of database class
$dbh = new db_conn();
$dbh->set_conn();

//getting news id by explode function
$path = ltrim($_SERVER['REQUEST_URI'], '/');
//echo "path = ".$path;
$b = explode("/", $path);
$id = explode(".", $b[1]);
$b_url = explode("-", $id[0]);
$b_id = $b_url[0];

$blog_id = $b_id;
$blog_t = explode($blog_id,$path);
$blog_tt =  explode('blog.php',$blog_t[1]);
$blog_ttt = substr($blog_tt[0],1);
$blog_tttt = rtrim($blog_ttt, "- ");
$blog_e = str_replace("-"," ",$blog_tttt);

$msg ="";
$flag = 0;
//echo "blog_id = ".$blog_id;
//return;

//==================================================================================================================
//fetching latest jobs from database
$sql_blogs = "select * from tbl_blogs ";
//$sql_blogs = $sql_blogs . " where status = 'ACTIVE' and blog_title = '".$blog_e."' and blog_type = 'ACT' and deleted = 0 and blog_id = ".$blog_id;
$sql_blogs = $sql_blogs . " where status = 'ACTIVE' and blog_type = 'Teaching-Qualification' and deleted = 0 and blog_id = ".$blog_id;

//echo "sql_blogs=".$sql_blogs;
//return;
$result_blogs = mysqli_query($dbh->link,$sql_blogs);
if($result_blogs)
{
$no_of_blogs = mysqli_num_rows($result_blogs);
}
if($no_of_blogs>0)
{
	
	$flag= 1;
	$rw_blogs = mysqli_fetch_array($result_blogs);	
	$blog_id         = $rw_blogs['blog_id'];
	$blog_title      = $rw_blogs['blog_title'];
	$blog_pre_desc   = $rw_blogs['blog_pre_desc'];
	$blog_desc       = $rw_blogs['blog_desc'];
	$written_by      = $rw_blogs['written_by'];
	$posting_dt      = $rw_blogs['posting_dt'];
	$blog_image_path = $rw_blogs['blog_image_path'];
	$meta_title      = $rw_blogs['meta_title'];
	$meta_desc       = $rw_blogs['meta_desc'];
	$og_title        = $rw_blogs['og_title'];
	$og_desc         = $rw_blogs['og_desc'];
	
	$blog_title_url = str_replace(" ","-",$blog_title); 
	$blog_title_url = str_replace("&","-",$blog_title_url); 
	$blog_title_url = str_replace("(","",$blog_title_url); 
	$blog_title_url = str_replace(")","",$blog_title_url); 
	$blog_title_url = str_replace("?","",$blog_title_url);
	$blog_title_url = str_replace(":","",$blog_title_url);
	$blog_title_url = str_replace("'","",$blog_title_url);
	$blog_title_url = str_replace("!","",$blog_title_url);
	$blog_title_url = str_replace(";","",$blog_title_url);
	$blog_title_url = str_replace("_","",$blog_title_url);
	$blog_title_url = str_replace("–","",$blog_title_url);
	$blog_title_url = str_replace("/","",$blog_title_url);
	$blog_title_url = str_replace(",","",$blog_title_url);
	$blog_title_url = str_replace("’","",$blog_title_url);
		
}
else
{
 $flag = 0;
 $msg = "No Blogs Found";	
}


//fetching latest blogs from database for sidebar
$sql_blogs2 = "select * from tbl_blogs ";
$sql_blogs2 = $sql_blogs2 . " where status = 'ACTIVE' and blog_type = 'Teaching-Qualification' and deleted = 0 ";
//if($blogs != "")
//{
//	$sql_blogs2 = $sql_blogs2 . " and blog_title like '%".$blogs."%'";
//}
$sql_blogs2 = $sql_blogs2 . " order by posting_dt DESC, blog_id DESC  limit 6";
//echo "sql_blogs2=".$sql_blogs2;
$result_blogs2 = mysqli_query($dbh->link,$sql_blogs2);
if($result_blogs2)
{
	$no_of_blogs2 = mysqli_num_rows($result_blogs2);
	
	for($i=0; $i<$no_of_blogs2; $i++)
	{
		$rw_blogs2 = mysqli_fetch_array($result_blogs2);
		
		$blog_id2[$i]         = $rw_blogs2['blog_id'];
		$blog_title2[$i]      = $rw_blogs2['blog_title'];
		
	}	
}


//==========================================
?>