tring to compare.. need help
Posted: Mon Jul 12, 2010 10:44 pm
Hey guys i'm trying to do something and i can't seem to get it done correctly. I have a preset amount of levels for a monster to be. These levels are 2-99. What i'm trying to do is go through each level 2-99, do a lookup in my monsters database, if the level is already there i would like nothing to happen, if the level is not there i'd like it to display the level so that i may know that i need to add a monster of this level. All the code is doing is listing the number all 2-99 and i only want it to list the numbers 2-99 that are already not used from the database.
Can anyone help me out here?
all fields in the database are not null tho. let me try to explain better what i'm trying to do. I'll include a SS of the database and a SS of the output and better try to explain what i want the output to come out as.
ok so as you can see in the database i have multiply monsters with the level of 2 and 63 as well as all of the other levels. All i'm trying to do is list all the numbers 2-99 that are not taken already so i know which levels i still need to add. So if the output as is, i'm trying to get the output to be like...
6 - 7 - 8 - 9 - 11 - 12 - 14 .. ect
because these are the levels i have not yet created monsters for.. i hope that this makes it easier. Thanks for the reply and i hope someone knows how to do this!
Can anyone help me out here?
Code: Select all
//we need a counter to go from 2 - 99
$count = 2;
while ($count <= 99){
$getlevels = 'select level from monsters';
DB::connect($DB_database);
$getlevelsresult = DB::query($getlevels, "get levels");
DB::close();
while ($row = mysql_fetch_assoc($getlevelsresult)) {
$levels = $row['level'];
}
if ($levels == $count){
$count++;
} else {
echo ''.$count.' -';
$count++;
}
}all fields in the database are not null tho. let me try to explain better what i'm trying to do. I'll include a SS of the database and a SS of the output and better try to explain what i want the output to come out as.
ok so as you can see in the database i have multiply monsters with the level of 2 and 63 as well as all of the other levels. All i'm trying to do is list all the numbers 2-99 that are not taken already so i know which levels i still need to add. So if the output as is, i'm trying to get the output to be like...
6 - 7 - 8 - 9 - 11 - 12 - 14 .. ect
because these are the levels i have not yet created monsters for.. i hope that this makes it easier. Thanks for the reply and i hope someone knows how to do this!