<?php
ini_set('display_errors',1);
session_start();
include('script/condb.php');

$PID=$_GET['ced'];

$sql= "SELECT * FROM wall_calculation where blocktype ='9 inches Hollow Block' AND PID='$PID' ";
$result =mysqli_query($con, $sql);
while($rows =mysqli_fetch_array($result)){
$d46 =$rows["walllength"];
$e46 =$rows["wallheight"];
$walltype =	$rows["walltype"];
$f46= 0.025;
	}
$sql2= "SELECT * FROM foundation_materials where MaterialDescription ='9 inches Hollow Block' AND PID='$PID' ";
$result2 =mysqli_query($con, $sql2);
while($rows2 =mysqli_fetch_array($result2)){
	$L36 =$rows2['COEQuantity'];
	//$l37 =CAST($L36);
	//$L36 =str_replace( ‘.’ , ‘.’, $L36) );
}
//-----------------------blocksetting----------------
$sql3= "SELECT * FROM upline_app_blocksettings where Block_name ='9 inches Hollow Block' ";
$result3 =mysqli_query($con, $sql3);
while($rows3 =mysqli_fetch_array($result3)){
	$M40 =$rows3['Block_mortars']; 
	$A_9 =$rows3['Block_width'];
}
//------------------receiveformiput---------------------
if(isset($_POST['check3'])){
$A_37=$_POST['A_37'];
$A_38=$_POST['A_38'];
$cementRatio=0.010256410;
$sandRatio=0.012121212;
	
	$a=$A_37 * $cementRatio * 2;
	$b=$A_38 * $sandRatio * 2;
	$stage1_mix_1 =$a+$b;
	
	$mortal=($d46+$e46) * $f46 * 0.2;
	
	//$A_9 =$mortal * $stage1_mix_1*$L36 ;
//-------------external wall---------------	
	$cmc1 =$A_9*$M40;
	$cmc2 =$L36/$stage1_mix_1;
	//$cmcResult1=($A_9*$M40)* $L36/$stage1_mix_1;
	$cmcResultext= number_format(($cmc1*$cmc2),0, ".", " ");
	
	$mbl="INSERT INTO `mortalblockcal` (`PID`, `walltype`, `cementmortal`, `cement`, `sand`) VALUES('$PID','$walltype', '$cmcResultext','$A_37', '$A_38')";
	
	$mb1=mysqli_query($con, $mbl);
	
	if($mb1){
		 header("Location:stagesofproject.php?id=$PID"); }
	
		//---------------internal wall----------------------------
	
	
	//echo 'Cement mortal mix value for Exteral Wall is '.''. ''. $cmcResultext.'<br>';
	//echo 'Cement mortal mix value is '.''. ''. $cmcResult1.'<br>';
//echo 'Cement mortal mix value is '.''. ''. $stage1_mix_1.'<br>';
	//echo 'Cement mortal mix value is '.''. ''. $mortal.'<br>';
	
	//echo 'Mortal value is'.''.  $cmc2 .'<br>';
	//echo 'Cement Mortal value is'.  $L36 .'<br>';
	//echo 'Cement Mortal2 value is'.  $cmc1;

	
	
	
	
	
	
	
}












?>