Guest User

Untitled

a guest
Feb 16th, 2018
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.63 KB | None | 0 0
  1. <?php
  2.  
  3. $servername = "xxx.xxx.x.xx";
  4. $username = "xxxxx";
  5. $password = "xxxxxxx";
  6. $dbname = "xxxxxx";
  7.  
  8. $conn = new mysqli($servername, $username, $password, $dbname);
  9. $conn->set_charset('utf8');
  10.  
  11. if(isset($_POST['consulta1']))
  12. {
  13. $result_cursos = "SELECT centrodb.RegistoManutencao.Id,
  14. DataRegisto,
  15. Pedido,
  16. Outro,
  17. Descricao,
  18. Funcionario,
  19. Imagem,
  20. Tratamento,
  21. Estado
  22.  
  23. FROM centrodb.RegistoManutencao LEFT OUTER JOIN centrodb.InfoLuvas
  24.  
  25. ON centrodb.InfoLuvas.Id = centrodb.RegistoManutencao.Colaborador
  26.  
  27. WHERE Estado IS NULL;";
  28. $resultado_cursos = mysqli_query($conn, $result_cursos);
  29.  
  30. $tabela1 .= '<div style="float: center" table align="center">';
  31.  
  32. $tabela1 .= '<table border="5">';
  33.  
  34. $tabela1 .= '<tr>';
  35.  
  36. $tabela1 .='<thead>';
  37.  
  38. $tabela1 .= '<tr>';
  39.  
  40. $tabela1 .= '<th>Nº Registo</th>';
  41.  
  42. $tabela1 .= '<th>Data</th>';
  43.  
  44. $tabela1 .= '<th>Pedido</th>';
  45.  
  46. $tabela1 .= '<th>Outro Local</th>';
  47.  
  48. $tabela1 .= '<th>Descrição</th>';
  49.  
  50. $tabela1 .= '<th>Colaborador</th>';
  51.  
  52. $tabela1 .= '<th>Imagem</th>';
  53.  
  54. $tabela1 .= '<th>Tratamento</th>';
  55.  
  56. $tabela1 .= '<th>Concluído</th>';
  57.  
  58. $tabela1 .= '</tr>';
  59.  
  60. $tabela1 .='</thead>';
  61.  
  62. $tabela1 .='<tbody>';
  63.  
  64. while($rows_cursos = mysqli_fetch_array($resultado_cursos)) {
  65.  
  66. $tabela1 .= '<tr>';
  67.  
  68. $tabela1 .= '<td>'.$rows_cursos['Id'].'</td>';
  69.  
  70. $tabela1 .= '<td>'.$rows_cursos['DataRegisto'].'</td>';
  71.  
  72. $tabela1 .= '<td>'.$rows_cursos['Pedido'].'</td>';
  73.  
  74. $tabela1 .= '<td>'.$rows_cursos['Outro'].'</td>';
  75.  
  76. $tabela1 .= '<td>'.$rows_cursos['Descricao'].'</td>';
  77.  
  78. $tabela1 .= '<td>'.$rows_cursos['Funcionario'].'</td>';
  79.  
  80. $tabela1 .= '<td> <input type="file" name= "Imagem" id= "Imagem" value="'.$rows_cursos['Imagem'].'"></td>';
  81.  
  82. $tabela1 .= '<td> <input type="text" name= "Tratamento" id= "Tratamento" value="'.$rows_cursos['Tratamento'].'"></td>';
  83.  
  84. $tabela1 .= '<td> <input type="checkbox" name= "Id[]" value="'.$rows_cursos['Id'].'"></td>';
  85.  
  86. $tabela1 .= '</tr>';
  87. }}
  88. $tabela1 .= '</tr>';
  89.  
  90. $tabela1 .='</tbody>';
  91.  
  92. $tabela1 .= '</table>';
  93.  
  94. $tabela1 .= '</div>';
  95.  
  96. echo "<form method='POST' action=''>";
  97.  
  98. echo $tabela1;
  99.  
  100. echo "<input type='submit' name='registar' value='Registo'>";
  101. echo "</form>";
  102.  
  103. ?>
  104.  
  105. <?php
  106. if(isset($_POST['registar']))
  107. {
  108. $servername = "192.168.0.26";
  109. $username = "centro";
  110. $password = "qQQ!000p";
  111. $dbname = "centrodb";
  112.  
  113. $conn = new mysqli($servername, $username, $password, $dbname);
  114. $conn->set_charset('utf8');
  115.  
  116. $registro = $_POST['Id'];
  117. $tratamento = $_POST['Tratamento'];
  118. $imagem = $_POST['Imagem'];
  119.  
  120. foreach($registro as $value) {
  121. $conn->query("UPDATE RegistoManutencao SET Estado = 'Concluido', Tratamento = '$tratamento', Imagem = '$imagem' WHERE Id=" . $value);
  122. }
  123. }
  124. ?>
Add Comment
Please, Sign In to add comment