forked from rpitv/rpits
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathaddteamcsv.php
31 lines (28 loc) · 1012 Bytes
/
addteamcsv.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<title>Team Roster Adder (via CSV)</title>
<?
include ("init.php");
mysql_select_db("rpihockey");
$team_sel = $_POST["team_sel"];
$csv = $_POST["csv"];
if($csv)
{
$lines = explode("\r\n",$csv);
foreach($lines as $line)
{
$values = explode('|',$line);
$query = "INSERT INTO players (num,first,last,pos,height,weight,year,hometown,team) VALUES ";
$query .= "('$values[0]','$values[1]','$values[2]','$values[3]','$values[4]','$values[5]','$values[6]','$values[7]','$team_sel')";
mysql_query($query) or die("<b>YOU DID SOMETHING WRONG YOU IDIOT</b>.\n<br />Query: " . $query . "<br />\nError: (" . mysql_errno() . ") " . mysql_error());
echo("Added " . $values[1] . " " . $values[2] . " to the team roster for " . $team_sel);
}
include("peditor.php");
}
else
{
?>
<form action="addteamcsv.php" method="POST">
<input type="text" name="team_sel" size="10" />
<textarea name="csv" rows="30" cols="100"></textarea>
<input type="submit" name="Submit" />
</form>
<? } ?>