Andreu | fd98b5d | 2019-09-22 13:15:10 +0200 | [diff] [blame] | 1 | <?php |
| 2 | require '../credentials.php'; |
| 3 | require '../php/utils.php'; |
Andreu | b78c879 | 2019-09-22 14:51:13 +0200 | [diff] [blame^] | 4 | |
| 5 | // Read from CSV |
| 6 | $inscrits = array_map('str_getcsv', file('inscrits.csv')); |
| 7 | array_shift($inscrits); // remove header |
Andreu | fd98b5d | 2019-09-22 13:15:10 +0200 | [diff] [blame] | 8 | |
Andreu | b78c879 | 2019-09-22 14:51:13 +0200 | [diff] [blame^] | 9 | $start = 1; |
Andreu | fd98b5d | 2019-09-22 13:15:10 +0200 | [diff] [blame] | 10 | $i = $start; |
| 11 | foreach ($inscrits as $user) { |
| 12 | $i = ($i + 1) % ($start + count($inscrits)); |
| 13 | if ($i == 0) $i = $i + 1; |
Andreu | b78c879 | 2019-09-22 14:51:13 +0200 | [diff] [blame^] | 14 | $template = "INSERT INTO `newusers` (`id`, `nom`, `curs`, `grau`, `quimata`, `requested`, `mort`, `password`)" . |
Andreu | fd98b5d | 2019-09-22 13:15:10 +0200 | [diff] [blame] | 15 | " VALUES (NULL, '".$user[0]."', '".$user[1]."', '".$user[2]."', ".$i.", '0', '0', '')"; |
Andreu | b78c879 | 2019-09-22 14:51:13 +0200 | [diff] [blame^] | 16 | if (query($template)) echo $template . "<br />"; |
Andreu | fd98b5d | 2019-09-22 13:15:10 +0200 | [diff] [blame] | 17 | } |
| 18 | ?> |