Hi,
I am trying to develop a room allocation application, but am struggling a bit to get my head around the coding. I am trying to break it down into small chunks and then maybe see if I can get everything to work together.
I have a mysql table which contains a list of users. I have returned the results of the user IDs from my select query into an array. I also have another table which holds a numeric marker. The marker will change.
My array of user IDs would look like: Array ( [0] => 1 [1] => 3 [2] => 5 )
My numeric marker could be: 1
What I need to do is do a complete loop through my array starting at the numeric marker position. This would return: [1]=>3 [2]=>5 [0]=>1
As you can see, it jumps back to the beginning of the array and outputs the first element to complete the loop. Depending on the numeric marker and this particular data set, the array could also run like:
Marker = 0: [0]=>1 [1]=>3 [2]=>5
Marker = 2: [2]=>5 [0]=>1 [1]=>3
I have had a go at writing the code and if I start at numeric marker 1, I can get it to run to the end of the array. I just have no idea how to reset back to the beginning and run until I reach numeric marker minus 1.
Here is what I have so far:
$i = $numericMarker; foreach ($userID as $key => $value) { if ($key < $numericMarker) continue; echo '$i = '.$i.' $value = '.$value.'<br />'; $i++; }
Any help you can give me would be greatly appreciated.
Many thanks,
John