Fixed bug + added insert
diff --git a/admin/insert.php b/admin/insert.php
index 8cb6f2a..77df79b 100644
--- a/admin/insert.php
+++ b/admin/insert.php
@@ -1,24 +1,18 @@
<?php
require '../credentials.php';
require '../php/utils.php';
+
+ // Read from CSV
+ $inscrits = array_map('str_getcsv', file('inscrits.csv'));
+ array_shift($inscrits); // remove header
- $inscrits = [
- ['Joan Hernanz Segarra', 3, 1],
- ['Olga Almudena Martínez', 1, 1],
- ['Jordi Ganso Rodríguez', 2, 0],
- ['Júlia Montserrat Puig', 3, 0],
- ['Berta Galofré Mestres', 4, 0],
- ['Laia Pomar Raventós', 3, 1],
- ['Irene Cusiné Baltà', 1, 0]
- ];
-
- $start = 6;
+ $start = 1;
$i = $start;
foreach ($inscrits as $user) {
$i = ($i + 1) % ($start + count($inscrits));
if ($i == 0) $i = $i + 1;
- $template = "INSERT INTO `users` (`id`, `nom`, `curs`, `grau`, `quimata`, `requested`, `mort`, `password`)" .
+ $template = "INSERT INTO `newusers` (`id`, `nom`, `curs`, `grau`, `quimata`, `requested`, `mort`, `password`)" .
" VALUES (NULL, '".$user[0]."', '".$user[1]."', '".$user[2]."', ".$i.", '0', '0', '')";
- if (query($template)) echo $template . "\n";
+ if (query($template)) echo $template . "<br />";
}
?>