Location: PHPKode > projects > Decider > decider/Fuzzy_Questionaire/fuzzy_questionairetab.php
<?php

	require('../Login/authen.php');

?>
<html>
<head>
<title>Decider - Information Gathering Assistant</title>
<link rel="stylesheet" type="text/css" href="../ajaxtabs/ajaxtabs.css" />
<link rel="stylesheet" type="text/css" href="../common/styles1.css" /> 

<script type="text/javascript" src="../ajaxtabs/ajaxtabs.js">
</script>

</head>
<body>
<div id='maindiv' align="center">
<table width="800px"><tr><td align="left" valign="top"><?php require('../common/top.html'); ?></td>
	</tr></table>
	
<table background="../common/tableback.png" width="800px" height="800px">
<tr align="right"><td></td><td class="label" align="right">
	<?php 
	
echo $_SESSION['username'];
?></td></tr>
	<tr>
	
		<td align="left" valign="top"><?php require('../common/menu.html'); ?></td>
		<td width="600px" align="left" valign="top"><?php require('../Fuzzy_Questionaire/fuzzy_questionaire.php'); ?></td>
	</tr>

</table>



<?php

//to add data to client table
if(isset($_POST['add'])){
	
	//selecting right domain name
	$domain_query = "select Domain_Name from key_person where Id='".$_POST[kp_id]."'";
	$result = mysql_query($domain_query, $link);
	$raw = mysql_fetch_array($result);		
	
	$domain = $raw['Domain_Name'];
	$kp_id = $_POST[kp_id];
	//----------------------------
	
	//checking answered questions
	for($i=0;$i<1000;$i++){
	
		$domain_weight=0.01;
		$kp_weight=0.01;
		
		$temp_wieght1=0; 
		$temp_weight2=0;
		$temp_answer="";
	
		//checking whether the check box has been checked
		if(isset($_POST[$i])){
		
			$textarea="textarea".$i;
			$radiobutton="rb".$i;
			
			
		//dealing with fuzzy_keyperson table	
			//determining whether values already exist in the table
			$domain_check_query1 = "select weight from fuzzy_keyperson where (not turn='0') and Q_Id='".$i."' and Domain='".$domain."' and Kp_Id='".$kp_id."'";
			$result1 = mysql_query($domain_check_query1, $link);
			$raw1=mysql_fetch_array($result1);		
	
			$temp_wieght1 = $raw1['weight'];
			$kp_weight = $raw1['weight'];
		//----------------------------------
		
		
		//dealing with fuzzy domian table	
			//determining whether values already exist in the table
			$domain_check_query2 = "select weight from fuzzy_domain where (not turn='0') and Q_Id='".$i."' and Domain='".$domain."'";
			$result2 = mysql_query($domain_check_query2, $link);
			$raw2=mysql_fetch_array($result2);		
	
			$temp_weight2 = $raw2['weight'];
			$domain_weight = $raw2['weight'];
		//-------------------------------
		
		//dealing with client_feedback table
			//determining whether values already exist in the table
			//$q_string="INSERT INTO client_feedback (Domain_Name, Keyperson_Id, Quiz_Id, Answer, turn) VALUES ('$domain','$_POST[kp_id]','$i','$_POST[$textarea]','$_POST[turn]')";
			
			$domain_check_query3 = "select Answer from client_feedback where (not turn='0') and Quiz_Id='".$i."' and Domain_Name='".$domain."' and Keyperson_Id='".$kp_id."'";
			$result3 = mysql_query($domain_check_query3, $link);
			$raw3=mysql_fetch_array($result3);		
	
			$temp_answer = $raw3['Answer'];
		//----------------------------------
		
			
			//checking the weights of the fuzziness
			if($_POST[$radiobutton]=="1"){
				//echo "veryclear";
				$kp_weight = $kp_weight + 0.08;
				$domain_weight = $domain_weight + 0.08;
			}	
			if($_POST[$radiobutton]=="2"){
				//echo "clear";
				$kp_weight = $kp_weight + 0.05;
				$domain_weight = $domain_weight + 0.05;
			}	
			if($_POST[$radiobutton]=="3"){
				//echo "messy"; 
				$kp_weight = $kp_weight + 0.02;
				$domain_weight = $domain_weight + 0.02;
			}
			if($_POST[$radiobutton]=="4"){
				//echo "noidea"; 
				$kp_weight = $kp_weight + 0.01;
				$domain_weight = $domain_weight + 0.01;
			}
			//-------------------------------------- 
			
			
			//setting query according to existing values in fuzzy_keyperson and executing query 
			if($temp_wieght1<0.01)
				
				$q_string1="INSERT INTO fuzzy_keyperson (Q_Id, Domain, kp_Id, weight, turn) VALUES ('".$i."','".$domain."','".$kp_id."','".$kp_weight."','".$_POST[turn]."')";
			
			else
			
				$q_string1="UPDATE fuzzy_keyperson SET weight='".$kp_weight."',turn='".$_POST[turn]."' where Q_Id='".$i."' and Domain='".$domain."' and Kp_Id='".$kp_id."'";
				
			
			if (!mysql_query($q_string1,$link)){
	  			die('Error: ' . mysql_error());
	  		}
			//---------------------------------------------------------------------------------
			
			
			//setting query according to existing values in fuzzy_domain and executing query 
			if($temp_wieght1<0.01)
				
				$q_string2="INSERT INTO fuzzy_domain (Q_Id, Domain, weight, turn) VALUES ('".$i."','".$domain."','".$kp_weight."','".$_POST[turn]."')";
			
			else
			
				$q_string2="UPDATE fuzzy_domain SET weight='".$kp_weight."',turn='".$_POST[turn]."' where Q_Id='".$i."' and Domain='".$domain."'";
				
			
			if (!mysql_query($q_string2,$link)){
	  			die('Error: ' . mysql_error());
	  		}
			//------------------------------------------------------------------------------
			
			
			//setting query according to existing values in client_feedback and executing query 
			if($temp_answer=="")
				
				$q_string3="INSERT INTO client_feedback (Quiz_Id, Domain_Name, Keyperson_Id, Answer, turn) VALUES ('".$i."','".$domain."','".$kp_id."','".$_POST[$textarea]."','".$_POST[turn]."')";
			
			else
			
				$q_string3="UPDATE client_feedback SET Answer='".$_POST[$textarea]."',turn='".$_POST[turn]."' where Quiz_Id='".$i."' and Domain_Name='".$domain."' and Keyperson_Id='".$kp_id."'";
				
			
			if (!mysql_query($q_string3,$link)){
	  			die('Error: ' . mysql_error());
	  		}
			//---------------------------------------------------------------------------------
			
		}
		
	}
	
	echo "records added";
	mysql_close($link);
	
}

?>

</div>
</body>
</html>



Return current item: Decider