<?php
require'../connections/conn.php';


$new_treat=$_GET['new_treat'];

$ch="select * from `treatments` where `treat_name`='$new_treat'";
$ch_r=$conn->query($ch);
if(mysqli_num_rows($ch_r)==0)
{
	$conn->query("insert into `treatments` (`treat_name`) values ('$new_treat')");
}

$main_app=$_GET['app_main'];
$app=$_GET['app'];
$treat=$_GET['treat'];
$p=$_GET['p'];

$old="select * from `appointment` where `app_id`=$app";
$rold=$conn->query($old);
while($row2=mysqli_fetch_array($rold))	
{
	echo $treat=($row2['treatment']);

}

 $all=$treat."
 ".$new_treat;
  $set="UPDATE `appointment` SET `treatment`='$all' WHERE  `app_id`=$app ";
	$s=$conn->query($set);
	
	
	echo "<script type='text/javascript'>window.location.href = 'detail.php?app_id=$main_app&&p_id=$p'</script>";
?>