Hi there!
I have a problem with inserting some values into my mysql-db. The script generates a match-schedule for a league with 8 teams.
After the schedule is generated I want to loop it into the db.
(I have a form that provides information for the script)
// The 2d-array that contains all the fixtures (14 rounds)
$omg = array(1 => array($lag1,$lag2,$lag3,$lag4,$lag5,$lag6,$lag7,$lag8),
2 => array($lag6,$lag1,$lag8,$lag3,$lag2,$lag7,$lag4,$lag5),
3 => array($lag3,$lag2,$lag5,$lag8,$lag6,$lag4,$lag7,$lag1),
4 => array($lag1,$lag4,$lag8,$lag6,$lag2,$lag5,$lag7,$lag3),
5 => array($lag3,$lag1,$lag5,$lag7,$lag6,$lag2,$lag4,$lag8),
6 => array($lag1,$lag8,$lag3,$lag5,$lag2,$lag4,$lag7,$lag6),
7 => array($lag5,$lag1,$lag6,$lag3,$lag8,$lag2,$lag4,$lag7),
8 => array($lag1,$lag5,$lag3,$lag6,$lag2,$lag8,$lag7,$lag4),
9 => array($lag8,$lag1,$lag5,$lag3,$lag4,$lag2,$lag6,$lag7),
10 => array($lag1,$lag3,$lag7,$lag5,$lag2,$lag6,$lag8,$lag4),
11 => array($lag4,$lag1,$lag6,$lag8,$lag5,$lag2,$lag3,$lag7),
12 => array($lag2,$lag3,$lag8,$lag5,$lag4,$lag6,$lag1,$lag7),
13 => array($lag1,$lag6,$lag3,$lag8,$lag7,$lag2,$lag5,$lag4),
14 => array($lag2,$lag1,$lag4,$lag3,$lag6,$lag5,$lag8,$lag7)
);
// Then I loop through the $omg-array and inserting the fixtures round by round
for($a = 1; $a <= 14; $a++) {
mysql_query("INSERT INTO $serie (id, omg, h1, b1, h2, b2, h3, b3, h4, b4) VALUES ('10', '$a', '$omg[$a][0]', '$omg[$a][1]', '$omg[$a][2]', '$omg[$a][3]', '$omg[$a][4]', '$omg[$a][5]', '$omg[$a][6]', '$omg[$a][7]')") or die("Query error!");
}
The insertion goes well but the fieldvalues for h1, b1, h2, b2, h3, b3, h4, b4 becomes Array[0], Array[1], Array[2], Array[3], Array[4], Array[5], Array[6], Array[7] instead of the team-names. It seems like it can't read the second dimension of the array...
I tried removing the singlequotes but then i get query error. How can I solve this?
Thanks
Vasse