daily pastebin goal
33%
SHARE
TWEET

Untitled

a guest Jul 20th, 2017 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. include "header2.php";
  3. ?>
  4. <?php
  5.  
  6. $servername = "localhost";
  7. $username = "root";
  8. $password = "";
  9. $dbname = "magang";
  10.  
  11. // Create connection
  12. $conn = new mysqli($servername, $username, $password, $dbname);
  13. // Check connection
  14. if ($conn->connect_error) {
  15.     die("Connection failed: " . $conn->connect_error);
  16. }
  17.  
  18. $sql = "SELECT * from kuesioner";
  19. $result = $conn->query($sql);
  20.  
  21. if ($result->num_rows > 0) {
  22.     // output data of each row
  23.     echo "<div style='width:100%; border: 1px solid #EBEBEB; overflow:scroll;height:900px;'>";
  24.     echo '<table width="100%">';
  25.     $urut = 0;
  26.     while($row = $result->fetch_assoc()) {
  27.         $id_soal=$row["id_soal"];
  28.             $soal=$row["soal"];
  29.             $pilihan_a=$row["A"];
  30.             $pilihan_b=$row["B"];
  31.             $pilihan_c=$row["C"];
  32.             $pilihan_d=$row["D"];
  33.  
  34.         ?>
  35.         <form name="form1" method="post" action="jawab.php">
  36.             <input type="hidden" name="id_user[]" value=<?php echo $id_soal; ?>>
  37.             <input type="hidden" name="id_soal[]" value=<?php echo $id_soal; ?>>    
  38.             <input type="hidden" name="jumlah" value=<?php echo $result->num_rows; ?>>
  39.             <tr>
  40.                 <td width="17"><font color="#000000"><?php echo $urut=$urut+1; ?></font></td>
  41.                 <td width="430"><font color="#000000"><?php echo "$soal"; ?></font></td>
  42.             </tr>
  43.                 <td height="21"><font color="#000000">&nbsp;</font></td>
  44.               <td><font color="#000000">
  45.              A.  <input name="pilihan[<?php echo $id_soal; ?>]" type="radio" value="1">
  46.               <?php echo "$pilihan_a";?></font> </td>
  47.             </tr>
  48.             <tr>
  49.                 <td><font color="#000000">&nbsp;</font></td>
  50.               <td><font color="#000000">
  51.              B. <input name="pilihan[<?php echo $id_soal; ?>]" type="radio" value="2">
  52.               <?php echo "$pilihan_b";?></font> </td>
  53.             </tr>
  54.             <tr>
  55.                 <td><font color="#000000">&nbsp;</font></td>
  56.               <td><font color="#000000">
  57.             C.  <input name="pilihan[<?php echo $id_soal; ?>]" type="radio" value="3">
  58.               <?php echo "$pilihan_c";?></font> </td>
  59.             </tr>
  60.             <tr>
  61.                 <td><font color="#000000">&nbsp;</font></td>
  62.               <td><font color="#000000">
  63.             D.   <input name="pilihan[<?php echo $id_soal; ?>]" type="radio" value="4">
  64.               <?php echo "$pilihan_d";?></font> </td>
  65.             </tr>
  66.  
  67.  
  68. <?php
  69.     }
  70. } else {
  71.     echo "0 results";
  72. }
  73. $conn->close();
  74.  
  75.  
  76.             ?>
  77.  
  78.             <tr>
  79.                 <td>&nbsp;</td>
  80.                 <td><center><input type="submit" name="submit" value="Jawab" onclick="return confirm('Apakah Anda yakin dengan jawaban Anda?')"></center></td>
  81.  
  82.             </tr>
  83.             </table>
  84. </form>
  85.         </p>
  86. </div>
  87.    
  88. <?php
  89. mysql_connect("localhost","root","");
  90. mysql_select_db("magang");
  91.  
  92.     $id_soal=$_POST["id_soal"];
  93.     $pilihan = $_POST["pilihan"];
  94.     $no = 0 ;
  95.  
  96.     foreach ($_POST['id_soal'] as $row) {
  97.     echo "<br>";
  98.     $a = $id_soal[$no];
  99.     echo $a;
  100.     echo "<b r>";
  101.     echo $pilihan[$a];
  102.     $no = $no + 1 ;
  103.     }  
  104.  
  105. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top