Advertisement
mayonismasin

Untitled

Jul 16th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.73 KB | None | 0 0
  1. <?php
  2.  
  3. $serverName = "LAPTOP-SOI03H0J"; //serverName\instanceName
  4. $connectionInfo = array( "Database"=>"pustaxa", "UID"=>"", "PWD"=>"");
  5. $conn = sqlsrv_connect($serverName, $connectionInfo);
  6. if( $conn ) {
  7. // echo "Connection established.<br />";
  8. }else{
  9. echo "Connection could not be established.<br />";
  10. die( print_r( sqlsrv_errors(), true));
  11. }
  12.  
  13.  
  14.  
  15. $output = array('data' => array());
  16.  
  17. $sql = "SELECT * FROM dbo.Kalendar";
  18.  
  19. $stmt = sqlsrv_query( $conn, $sql );
  20. if( $stmt === false) {
  21. die( print_r( sqlsrv_errors(), true) );
  22. }
  23.  
  24.  
  25.  
  26. $x = 1;
  27. while( $row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_ASSOC) ) {
  28.  
  29. $active = '';
  30. $PDMSabah = '';
  31. $PDMSarawak = '';
  32. $PDMUtara = '';
  33. $PDMTimur = '';
  34. $PDMSelatan = '';
  35.  
  36. if($row['PDMKL'] == 1) {
  37. $active = '<label class="label label-success">Bekerja</label>';
  38. } else {
  39. $active = '<label class="label label-danger">Cuti</label>';
  40. }
  41.  
  42. if($row['PDMSabah'] == 1) {
  43. $PDMSabah = '<label class="label label-success">Bekerja</label>';
  44. } else {
  45. $PDMSabah = '<label class="label label-danger">Cuti</label>';
  46. }
  47.  
  48. if($row['PDMSarawak'] == 1) {
  49. $PDMSarawak = '<label class="label label-success">Bekerja</label>';
  50. } else {
  51. $PDMSarawak = '<label class="label label-danger">Cuti</label>';
  52. }
  53.  
  54. if($row['PDMTimur'] == 1) {
  55. $PDMTimur = '<label class="label label-success">Bekerja</label>';
  56. } else {
  57. $PDMTimur = '<label class="label label-danger">Cuti</label>';
  58. }
  59.  
  60. if($row['PDMUtara'] == 1) {
  61. $PDMUtara = '<label class="label label-success">Bekerja</label>';
  62. } else {
  63. $PDMUtara = '<label class="label label-danger">Cuti</label>';
  64. }
  65.  
  66. if($row['PDMSelatan'] == 1) {
  67. $PDMSelatan = '<label class="label label-success">Bekerja</label>';
  68. } else {
  69. $PDMSelatan = '<label class="label label-danger">Cuti</label>';
  70. }
  71.  
  72. $actionButton = '
  73. <div class="btn-group">
  74. <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
  75. Action <span class="caret"></span>
  76. </button>
  77. <ul class="dropdown-menu">
  78. <li><a type="button" data-toggle="modal" data-target="#editMemberModal" onclick="editMember('.$row['idKalendar'].')"> <span class="glyphicon glyphicon-edit"></span> Edit</a></li>
  79. <li><a type="button" data-toggle="modal" data-target="#removeMemberModal" onclick="removeMember('.$row['idKalendar'].')"> <span class="glyphicon glyphicon-trash"></span> Remove</a></li>
  80. </ul>
  81. </div>';
  82.  
  83. $date = $row['Tarikh'];
  84. //$newDate = date_format($date,"Y/m/d H:i:s");
  85.  
  86. $output['data'][] = array(
  87. $date,
  88. $active,
  89. $PDMSabah,
  90. $PDMSarawak,
  91. $PDMTimur,
  92. $PDMUtara,
  93. $PDMSelatan,
  94. $actionButton
  95. );
  96.  
  97. $x++;
  98. }
  99.  
  100. // database connection close
  101.  
  102. echo json_encode($output);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement