Waarde uit een array
Nu wil ik de tabel gaan aanpassen door een waarde uit de array te vergelijken met die uit de tabel.
De array heeft deze structuur:
Code (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
32
33
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
32
33
Array
(
[0] => Array
(
[nf] => AUS
[combinationID] => 108
[horseFEIid] => 102VN37
[personFEIid] => 10009036
[compNumber] => 0
[is_nc] => No
[is_waitingList] => No
[combinationLocked] => No
[dateAdded] => 2014-09-18 14:14:58
[dateEdit] => 2014-09-16 14:23:47
)
[1] => Array
(
[nf] => AUT
[combinationID] => 20
[horseFEIid] => 102VP001
[personFEIid] => 10009036
[compNumber] => 0
[is_nc] => No
[is_waitingList] => No
[combinationLocked] => No
[dateAdded] => 2014-09-18 14:14:58
[dateEdit] => 2014-09-16 14:23:47
)
Etc
}
(
[0] => Array
(
[nf] => AUS
[combinationID] => 108
[horseFEIid] => 102VN37
[personFEIid] => 10009036
[compNumber] => 0
[is_nc] => No
[is_waitingList] => No
[combinationLocked] => No
[dateAdded] => 2014-09-18 14:14:58
[dateEdit] => 2014-09-16 14:23:47
)
[1] => Array
(
[nf] => AUT
[combinationID] => 20
[horseFEIid] => 102VP001
[personFEIid] => 10009036
[compNumber] => 0
[is_nc] => No
[is_waitingList] => No
[combinationLocked] => No
[dateAdded] => 2014-09-18 14:14:58
[dateEdit] => 2014-09-16 14:23:47
)
Etc
}
Onderstaande code gebruik ik om dit te doen:
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
2
3
4
5
6
7
8
9
10
11
12
$compStart = 200;
$x = 0;
while ($x < $numberComb)
{
echo "UPDATE `2010Combination`
SET `compNumber` = '".$compStart."' ,`combinationLocked` = 'Yes'
WHERE `2010Combination`.`combinationID` = `".$arrAll[$x][combinationID]."`
";
$compStart++;
echo $x."<BR/>";
$x++;
}
$x = 0;
while ($x < $numberComb)
{
echo "UPDATE `2010Combination`
SET `compNumber` = '".$compStart."' ,`combinationLocked` = 'Yes'
WHERE `2010Combination`.`combinationID` = `".$arrAll[$x][combinationID]."`
";
$compStart++;
echo $x."<BR/>";
$x++;
}
De foutmelding die ik krijg is Notice: Use of undefined constant combinationID - assumed 'combinationID'
in deze regel: WHERE `2010Combination`.`combinationID` = `".$arrAll[$x][combinationID]."`
De vraag is of ik de array wel geod uitlees?
Daarnaast: haal die ` overal weg. Niet nodig.
Het kan alleen zijn:
$arrAll[$x][$combinationID]
of
$arrAll[$x]['combinationID'] // deze dus lijkt mij
Gewijzigd op 19/09/2014 23:43:59 door Frank Nietbelangrijk
Je vergeet nog een variant ;-)
"$arrAll[$x][combinationID]"
alhoewel die binnen de ondoorgrondelijke ontwerpprincipes van PHP valt...
@Frank, dat was het. Dit probleem ook weeer opgelost.