<?php

include_once "library/inc.connection.php";
include_once "library/inc.library.php";

// $id = $_GET['id'];
 //$user = $_GET['user'];
 
if (isset ($_POST ['update_user']))
	{
	$id_user = $_POST['id_user'];
	$nama_lengkap = $_POST['nama_lengkap'];
	$username = $_POST['username'];
	$password = $_POST['password'];
	$jenis_kelamin = $_POST['jenis_kelamin'];
	$status = $_POST['status'];
	
	$status = $_POST['status'];
$update = mysql_query("update user set nama_lengkap='$nama_lengkap', username='$username', password='$password', jenis_kelamin='$jenis_kelamin', status='$status' where id_user='$id_user'");
mysql_close();
if ($update) {
    echo "<script type=\"text/javascript\">
						alert(\"Data Telah di Update\");
						window.location = \"tabel_user.php\"
					</script>";
} else {
     echo "<script type=\"text/javascript\">
						alert(\"Data gagal di Update\");
						window.location = \"tabel_user.php\"
					</script>";
	}
}



elseif (isset ($_POST['update_gejala']))
	{
	$id_gejala = $_POST['id_gejala'];
	$get = "delete from aturan where id_gejala ='$id_gejala'";
	$del = mysql_query ($get);
		$nama_gejala = $_POST['nama_gejala'];
		$query2 = mysql_query("SELECT count(id_gejala) as jumlah FROM gejala");
			while ($row = mysql_fetch_array($query2) ) 
			{
			$jumlah=$row['jumlah'];
			}
		if(isset($_POST["id_penyakit"]))  
        { 
            // Retrieving each selected option 
			$as=1;
			 foreach ($_POST['id_penyakit'] as $id_penyakita)  
               {
				$as=$as+1;
				}
            foreach ($_POST['id_penyakit'] as $id_penyakit)  
               {
			   $np=$as/$jumlah;
			   $queryc = "INSERT INTO aturan (id_penyakit,id_gejala,nilai_probabilitas) VALUES
				('$id_penyakit','$id_gejala','$np')";
				$hasilc = mysql_query($queryc);
			
				}
			
        } 
$update = mysql_query("update gejala set nama_gejala='$nama_gejala' where id_gejala='$id_gejala'");
mysql_close();
if ($update) {
     echo "<script type=\"text/javascript\">
						alert(\"Data Telah di Update\");
						window.location = \"tabel_gejala.php\"
					</script>";
} else {
    echo "<script type=\"text/javascript\">
						alert(\"Data gagal di Update\");
						window.location = \"tabel_gejala.php\"
					</script>";

	
}
}

elseif (isset ($_POST['update_penyakit']))
	{
	
	$id_penyakit = $_POST['id_penyakit'];
		$nama_penyakit = $_POST['nama_penyakit'];
		$keterangan = $_POST['keterangan'];
$update = mysql_query("update penyakit set nama_penyakit='$nama_penyakit', keterangan='$keterangan' where id_penyakit='$id_penyakit'");
mysql_close();
if ($update) {
     echo "<script type=\"text/javascript\">
						alert(\"Data telah di Update\");
						window.location = \"tabel_penyakit.php\"
					</script>";
} else {
   echo "<script type=\"text/javascript\">
						alert(\"Data gagal di Update\");
						window.location = \"tabel_penyakit.php\"
					</script>";

	
}
}
elseif (isset ($_POST['update_solusi']))
	{
	
	$id_solusi = $_POST['id_solusi'];
		$id_penyakit = $_POST['id_penyakit'];
		$keterangan = $_POST['keterangan'];
$update = mysql_query("update solusi set id_penyakit='$id_penyakit', solusi='$keterangan' where id_solusi='$id_solusi'");
mysql_close();
if ($update) {
     echo "<script type=\"text/javascript\">
						alert(\"Data telah di Update\");
						window.location = \"tabel_solusi.php\"
					</script>";
} else {
   echo "<script type=\"text/javascript\">
						alert(\"Data gagal di Update\");
						window.location = \"tabel_solusi.php\"
					</script>";

	
}
}

?>