<META NAME="robots" CONTENT="noindex,nofollow">


<?php
	include_once("simple_html_dom.php");
	include_once("ConnectToMarketData.php");    

		$html = file_get_html("https://investorzone.in/buyback/");
    	$tbody = $html->find('tbody',0);
		if(!$tbody)
		{
			throw new Exception('Exception message');
		}
		$gainers["BUYBACK"] = array();
		$tmp = $tbody->find('tr',0);
		if(!$tmp)
		{
				throw new Exception('Exception message');
		}
		$first = true;
		
		foreach($tbody->find('tr') as $tr)
		{
			if($first)
			{
				$sql = "DELETE FROM `buyback`";
				$con->query($sql);
				$first = false;
			}
			
			$name = trim($tr->find('td', 0)->plaintext);
		    $price = trim($tr->find('td', 1)->plaintext);
			$type = trim($tr->find('td', 2)->plaintext);
			$bmeeting = trim($tr->find('td', 3)->plaintext);
			$rdate = trim($tr->find('td', 4)->plaintext);
			$odate = trim($tr->find('td', 5)->plaintext);
			$cdate = trim($tr->find('td', 6)->plaintext);
			$href = trim($tr->find('td', 0)->find('a',0)->href);
			
			$gainer = array(
				'NAME'=>$name,
				'PRICE'=>$price,
				'TYPE'=>$type,
				'BMEET'=>$bmeeting,
				'RDATE'=>$rdate,
				'ODATE'=>$odate,
				'CDATE'=>$cdate,
				'HREF'=>$href
			);
			
			$sql = "INSERT INTO `buyback` (`name`, `price`, `type`, `bmeeting`, `rdate`, `odate`,`cdate`,`href`) VALUES ('$name', '$price','$type', '$bmeeting', '$rdate', '$odate', '$cdate', '$href');";
			$con->query($sql)