Yea, it's just the function, don't worry, I got all the variables covered and tested, they work as they should.
- Now the main problem:
- The mysql_fetch_array only returns record by record (so one at a time), not the whole array so you won't have all the slotnum the way you do your thing...
Not sure if I know what you mean, so, I should just change $res to $res['0']? -Sorry, still learning. =P
@Rifke Ooh yea, I see, stupid me. >.<
And I'm trying not too take everything from your code, since I didn't get the "this->" part, and I figured it should work this way too.
OK, the code I have now is:
- function getFreeSlot()
- {
- $sql = mysql_query("SELECT slotnum FROM storage WHERE owner = 80 ORDER BY slotnum DESC");
- $res = mysql_fetch_array($sql); //Uitkomst van sql
- $sql = sprintf($sql,$boolres);
- $x = 159;
-
- while ($x >= 1)
- {
- if (in_array($x,$res))
- {
- $x--;
- }
- else
- {
- break;
- }
- }
- return $x;
- }
Could you show me an example of how the fix the error I made, of which Lmame was talking?
P: Now it did use another slot, but it only goes down by one from 159, after that it wont go down. (Guess you already knew that would happen but thought I'd share it with you. =P)