$headersdone = FALSE; while (($line = fgets($h))!==FALSE) { $line = csvstring_to_array(trim($line)); if (!$headersdone) { $col = 0; foreach ($line as $value) { $value = strtolower($value); if (isset($headers[$value])) $headers[$value] = $col; elseif (isset($cats[$value])) { $cats[$col] = $cats[$value]; addEve($cats[$value]); } $col++; } } else { $ncomp++; // $country = strict_query("SELECT id FROM countries WHERE name=?", array($line[$headers["country"]])); if (!sql_num_rows($country)) $errors .= "Country name \"".$line[$headers["country"]]."\" not found in database<br>"; else { $birthday = $line[$headers["birth date"]];
$xlsx->setActiveSheetIndex($sn); $sheet = $xlsx->getActiveSheet(); $title = $sheet->getTitle(); $pos = strpos($title,"-"); if ($pos===FALSE) error ("Invalid sheet title format ('$title')."); $abbr = substr($title,0,$pos); if ($abbr!=$lastabbr) { $lastabbr = $abbr; $category = strict_query("SELECT * FROM categories WHERE abbr=?", array($abbr)); if (sql_num_rows($category)!=1) error ("Sheet title doesn't match any event abbreviation ('$abbr')"); $evtid = (int)cased_mysql_result($category,0,"id"); $timetype = cased_mysql_result($category,0,"timetype"); $inseconds = cased_mysql_result($category,0,"inseconds"); $round = 1; addEve($evtid); } else $round++; echo "Processing <b>".cased_mysql_result($category,0,"name")." - round $round</b> sheet..."; $fmtst = substr($sheet->getCell("A2")->getValue(), 8); $format = strict_query("SELECT * FROM formats WHERE name=?", array($fmtst)); if (sql_num_rows($format)!=1) error ("Invalid format ('$fmtst') at cell A2"); $formatid = cased_mysql_result($format,0,"id"); $times = cased_mysql_result($format,0,"times"); $avgtype = cased_mysql_result($format,0,"avgtype"); $i = 5; while ($sheet->getCell("B$i")->getValue()) {