<!doctype html public "-//w3c//dtd html 3.2//en">

<html>

<head>
<title>LGU drop down list box</title>
</head>

<body>
<?Php

$cat=$_POST['cat'];
$subcat=$_POST['subcat'];
$subcat3=$_POST['subcat3'];

echo " PSGC-Region = $cat <br> PSGC-Province = $subcat <br> Municipality/City = $subcat3 ";

?>
<br><br>
<a href=dd3.php>Reset and Try again</a>
<br><br>

<?php
require "config.php";
$dbo=mysqli_connect($dbhost_name,$username,$password,$database);
// Check connection
if (mysqli_connect_errno()) {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
}


mysqli_query($dbo,"INSERT INTO vwnu_joodb_Trainings (Municipality, PSGC_Province, PSGC_Region)
VALUES ('$subcat3','$subcat','$cat')");

mysqli_query($dbo,"UPDATE vwnu_joodb_Trainings t1
        INNER JOIN category t2 
             ON t1.PSGC_Region = t2.cat_id
SET t1.Region = t2.category where t1.Region is null");

mysqli_query($dbo,"UPDATE vwnu_joodb_Trainings t3
        INNER JOIN subcategory t4 
             ON t3.PSGC_Province = t4.subcat_id
SET t3.Province = t4.subcategory where t3.Province is null");

mysqli_query($dbo,"UPDATE vwnu_joodb_Trainings t5
        INNER JOIN subcategory2 t6 
             ON t5.Municipality = t6.subcat2
SET t5.PSGC_Municipality = t6.PSGC_Municipality where t5.PSGC_Municipality is null");

mysqli_query($dbo,"UPDATE vwnu_joodb_Trainings 
        SET state = 1 where title is null");

mysqli_query($dbo,"UPDATE vwnu_joodb_Trainings 
        SET title = concat(`Municipality`,', ',`Province`,', ',`Region`,' - ') where title is null");

mysqli_query($dbo,"UPDATE vwnu_joodb_Trainings t7
        INNER JOIN cca_mlgoo_assignments t8 
             ON t7.Municipality = t8.subcat2
SET t7.userid = t8.userid where t7.userid is null");


mysqli_close($dbo);
?>

</body>

</html>