Reputation: 53
ok i have a lvlcheck.php that compares the players experience and outputs the correct lvl based on experience. yet i cany get it to work. nothing shows up when i echo $lvl. its like all the the statements in lvlcheck.php are failing. below is my code.
this is my array to draw user stat experience
$sql = 'SELECT a.user, a.' . $stat1 .', b.' . $stat2 .'
FROM curstats a, experience b
WHERE a.user = b.user order by ' . $stat2 .' desc LIMIT 15';
$result = mysql_query($sql) or die(mysql_error());
array();
$rank = 1;
while($row = mysql_fetch_assoc($result)) {
?>
<tr>
<td align="center"><font color="#d3d3d3"><?php echo $rank++; ?></font></td>
<td align="center"><font color="#d3d3d3"><?php echo $row['user'];?></font></td>
<td align="center"><font color="#d3d3d3"><?php echo $row[$stat2]; ?></font></td>
<td align="center"><font color="#d3d3d3"><?php
$stat3 = $row['stat2'];
require 'includes/lvlcheck.php';
echo $lvl;
?></font></td></tr>
<?php
}
?>
and here is my lvl check. code.
<?php
if($stat3 > 0 && $stat3 < 83) {
$lvl = "1";
}
if($stat3 > 83 && $stat3 < 174) {
$lvl = "2";
}
if($stat3 > 174 && $stat3 < 276) {
$lvl = "3";
}
if($stat3 > 276 && $stat3 < 388) {
$lvl = "4";
}
if($stat3 > 388 && $stat3 < 512) {
$lvl = "5";
}
i know its the variables $stat1 and $stat2 are being assigned correctly because it will display the right experience just wont convert the the experience into a lvl to output $lvl any idea?
Upvotes: 1
Views: 69
Reputation: 53
I had to remove the quotation marks surrounding $stat2
in $stat3= $row['$stat2'];
Now, it reads $stat3 = $row[$stat2];
.
Upvotes: 0
Reputation: 14983
< 83
means less than 83, so the highest valid value would be 82
> 83
means greater than 83, so the lowest valid value would be 84
If you checking for 83, you won't get results.
<= 83
means less than or equal, so 83 would be included. For example...
Upvotes: 2