<?php
session_start();

/* Connection to MySQL Database*/
$host="server358.mysite4now.com";
$user="cooladmin";
$password="chillme";
$database="emissions";
//Connection
mysql_select_db($database, mysql_connect($host, $user, $password));

if(!empty($_POST['modelsubcat'])) {
	$car_id = $_POST['modelsubcat'];
	
	$car_query="SELECT CAR_YEAR,MODEL,CONSUMPTION,EMISSION FROM car_emissions WHERE CAR_ID =".$car_id."";
	
	$car_result = mysql_query($car_query);
	$result = mysql_fetch_array($car_result);
	$year = $result['CAR_YEAR'];
	$make_type = $result['MAKE_TYPE'];
	$consumption = $result['CONSUMPTION'];
	$emission = $result['EMISSION'];
	$totalcons = $consumption * $_POST['kmselect'] / 100 ;
	$totalemit = $emission * $_POST['kmselect'];
	$annualoffset = $totalemit * 0.02;
	$yearnum = $_POST['xyears'];
	$totaloffset = $annualoffset * $yearnum;
	$averageannual = 0.2843 * 20000;	
} else {
	$error = "<div style='padding: 50px; height:330px;'><h2>Please go to the previous page and make sure you have selected your vehicles model</h2><br /><a href='index.php?calc=car'>Back</a></div>";
}


?>