<?php

	include('db-connect.php');



	// $row1 = mysqli_query($con,"SELECT *,trfstandards.iddpicategory as iddpicategoryid,trfstandards.idprotectioncategory as idprotectioncategoryid,trfstandards.idstandards as idstandardsid FROM trfstandards LEFT JOIN standards ON trfstandards.idstandards=standards.idstandards LEFT JOIN dpicategory ON trfstandards.iddpicategory=dpicategory.iddpicategory LEFT JOIN protectioncategory ON trfstandards.idprotectioncategory=protectioncategory.idprotectioncategory WHERE trfstandards.idtrfdetails='{$_GET['idtrf']}' order by standardcode");

	$query = "select t.idtrfstandards, t.idstandards, s.standardcode, t.idprotectioncategory as idprotectioncategoryid, p.name_protectioncategory, t.iddpicategory as iddpicategoryid, d.value_dpicategory

			from trfstandards t

			left join standards s

			on t.idstandards = s.idstandards

			left join dpicategory d

			on t.iddpicategory = d.iddpicategory

			left join protectioncategory p

			on t.idprotectioncategory = p.idprotectioncategory

			where 1

			and t.idtrfdetails = {$_GET['idtrf']}

			order by s.standardcode;";

	$row1 = mysqli_query($con, $query);



	$rowcount=mysqli_num_rows($row1);



	$html = "";



	if($rowcount > 0){



		$html = "<table class=\"table table-striped mb-0\" id=\"example1\" style=\"border:1px solide red\">

				<tr>

					<th style=\"display:none;\">id</th>

					<th>{$_GET['standardcodetitle']}</th>

					<th>{$_GET['protectioncategorytitle']}</th>

					<th>{$_GET['dpicategorytitle']}</th>

				</tr>";

				

				while($rowquery = mysqli_fetch_assoc($row1)) {

$nameprotcatrec=html_entity_decode($rowquery['name_protectioncategory']);



					$this_pcat = (isset($rowquery['name_protectioncategory']))? $nameprotcatrec: $_GET['pleaseselectstd'];



					$this_dpcat = (isset($rowquery['value_dpicategory']))? $rowquery['value_dpicategory']: $_GET['pleaseselectstd'];



					$html .= "<tr>

								<td style=\"display:none;\">{$rowquery['idtrfstandards']}</td>

								<td>{$rowquery['standardcode']}</td>

								<td onclick=\"getSelectOptions('{$rowquery['idstandards']}','idprotectioncategory', '{$rowquery['idprotectioncategoryid']}');\">{$this_pcat}</td>

								<td onclick=\"getSelectOptions('{$rowquery['idstandards']}','iddpicategory', '{$rowquery['iddpicategoryid']}');\">{$this_dpcat}</td>

							</tr>";

				}

				

		$html .= "</table>";



	}



	echo $html;

?>