|
Hi,
I am having a strange issue with some PHP code I havent come across before.
The code is supposed to take the result from a query and store in $compositionResult. The result I know is a list of integers, it then cycles through and reads them into an array.
The second while loop is there to loop through a different result set and check if any item of the compArray is found in the id column of the second result. I have tried using gettype() and it confirms they are both strings so I am casting them to int. However regardless of what I do on that conditional expression it will not return true. I have echo'd the two variables to the screen and it is looping as I expect and at 6 points the condition should be true.
Is there something I am missing with regard to arrays perhaps or pointers? Any help would be greatly appreciated.
CODE:
$compositionResult = mysql_query($dbquery) or die(mysql_error());
$mark = 0;
WHILE($compositionRow = mysql_fetch_array($compositionResult)){
$compArray[$mark] = $compositionRow['compositionId'];
$mark++;
}
WHILE ($row = mysql_fetch_array($result)){
$tempid = $row['id'];
$mark = 0;
$count = count($compArray);
$select = "";
WHILE ($mark < $count){
IF( (int)$compArray[$mark] == (int)$tempId ){
$select = "selected";
ECHO "MATCH";
}
$mark++;
}
}
|