<?php
require("config/koneksi.php");
require("config/function.php");
require("config/crud.php");
$id_siswa = $_POST['id_siswa'];
$id_bank = $_POST['id_bank'];
$id_ujian = $_POST['id_ujian'];
$id_soal = $_POST['id_soal'];
$jenis = '5';

 $urutkan1 = $_POST['urutkan1'];
$urutkan2 = $_POST['urutkan2'];
$urutkan3 = $_POST['urutkan3'];
$urutkan4 = $_POST['urutkan4'];
$urutkan5 = $_POST['urutkan5'];

 if($urutkan1<>'' AND $urutkan2==''){$jawab = $urutkan1;}
 if($urutkan1<>'' AND $urutkan2<>''){$jawab = $urutkan1.', '.$urutkan2;}
  if($urutkan1<>'' AND $urutkan2<>'' AND $urutkan3<>''){$jawab = $urutkan1.', '.$urutkan2.', '.$urutkan3;}
   if($urutkan1<>'' AND $urutkan2<>'' AND $urutkan3<>'' AND $urutkan4<>''){$jawab = $urutkan1.', '.$urutkan2.', '.$urutkan3.', '.$urutkan4;}
    if($urutkan1<>'' AND $urutkan2<>'' AND $urutkan3<>'' AND $urutkan4<>'' AND $urutkan5<>''){$jawab = $urutkan1.', '.$urutkan2.', '.$urutkan3.', '.$urutkan4.', '.$urutkan5;}
$cekdata = "SELECT * FROM jawaban WHERE id_siswa='$id_siswa' AND id_ujian='$id_ujian' AND id_soal='$id_soal' AND jenis='$jenis'";
$jikaada = mysqli_query($koneksi,$cekdata);
if(mysqli_num_rows($jikaada)>0){
	
$exec = mysqli_query($koneksi, "UPDATE jawaban SET jawaburut='$jawab' WHERE id_siswa='$id_siswa' AND id_ujian='$id_ujian' AND id_soal='$id_soal' AND jenis='$jenis'");
		
		
	}else{
		
$exec = mysqli_query($koneksi, "INSERT INTO jawaban (id_siswa,id_bank,id_soal,id_ujian,jawaburut,jenis) VALUES ('$id_siswa','$id_bank','$id_soal','$id_ujian','$jawab','$jenis')");
	
		
	
		}


?>