Advertisement
lepasekat

Untitled

Jul 29th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 KB | None | 0 0
  1. <?php
  2.  
  3.  
  4. require_once ("../conn/conn.php");
  5. class updateDisplay{
  6. function getDataById(){
  7.  
  8. // new objeck from conn.php
  9. $connection = new Connection();
  10. $conn = $connection->getConnection();
  11.  
  12. $response = array();
  13.  
  14. $idmahasiswa = $_GET['id_mahasiswa'];
  15.  
  16. try{
  17. $sqlDisplayData = "SELECT * FROM mahasiswa WHERE id_mahasiswa=$idmahasiswa";
  18. $result = $conn->prepare($sqlDisplayData);
  19. $result->execute();
  20. $DataById = $result->fetchAll(PDO::FETCH_ASSOC);
  21.  
  22. foreach($DataById as $data ){
  23. ?>
  24. <table align="center">
  25. <form method="post" action="update.php?id_mahasiswa=<?php echo $_GET['id_mahasiswa'];?>" enctype="multipart/form-data">
  26. <tr>
  27. <td>Nama</td>
  28. <td>:</td>
  29. <td><input type="text" name="nama" value="<?php echo $data['nama']?>" placeholder="Masukkan Nama"></td>
  30. </tr>
  31. <tr>
  32. <td>NIM</td>
  33. <td>:</td>
  34. <td><input type="text" name="nim" value="<?php echo $data['nim']?>"placeholder="Masukkan NIM"></td>
  35. </tr>
  36. <tr>
  37. <td>Fakultas</td>
  38. <td>:</td>
  39. <td><input type="text" name="fakultas" value="<?php echo $data['fakultas']?>" placeholder="Masukkan Fakultas"></td>
  40. </tr>
  41. <tr>
  42. <td>Prodi</td>
  43. <td>:</td>
  44. <td><input type="text" name="prodi" value="<?php echo $data['prodi']?>" placeholder="Masukkan Prodi"></td>
  45. </tr>
  46. <tr>
  47. <td colspan="2" align="right"><input type="submit" name="submit" value="Update"></td>
  48. </tr>
  49. </form>
  50. </table>
  51. <?php
  52.  
  53.  
  54. }
  55. }catch (PDOException $e){
  56. echo "Gagal mengupdate data: ". $e->getMessage();
  57. }
  58. }
  59. }
  60.  
  61. $displayDataForUpdate = new updateDisplay();
  62. $displayDataForUpdate->getDataById();
  63. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement