Guest User

Untitled

a guest
Jun 24th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. <?php
  2.  
  3. //conexao
  4.  
  5. function resultado($dados) {
  6. $resultados = array_fill(1, 8, 0);
  7.  
  8. if (is_array($dados)) {
  9. foreach ($dados as $k => $v) {
  10. $resultados[$k] = $v;
  11. }
  12. } else {
  13. $resultados[(int)$dados] = 1;
  14. }
  15. return $resultados;
  16. }
  17.  
  18. for ($i = 1; $i <= 10; $i++) {
  19. $temp = array($i);
  20. $temp = array_merge($temp, resultado($_POST['p'. $i]));
  21.  
  22. mysql_query(vsprintf('INSERT INTO respostas VALUES (NULL, %d, %d, %d, %d, %d, %d, %d, %d, %d)', $temp));
  23. }
  24.  
  25. ?>
Add Comment
Please, Sign In to add comment