I'm working with a database where people have "kills" (a gaming database). What I want to display on their profile page is, instead of just a number, a graphic for each "kill" they have. For example, if "Bob" has 3 kills, I want the page to display 3 star images instead of the number 3.
The table (as an example) I'm working with is like this :
|-----------------------------|
|ID NAME KILLS DMGs |
|-----------------------------|
| 1 Bob 3 5 |
| 2 Rick 1 3 |
| 3 Tom 0 1 |
| 4 Dan 2 5 |
|-----------------------------|
The list of users, and their statistics, is being generated by a "While" statement - like so :
$sql = "SELECT * FROM users ORDER BY id ASC";
$result = @mysql_query($sql, $connect) or die(mysql_error());
while ($row = mysql_fetch_array($result)) {
$id = $row['id'];
$name = $row['name'];
$kills = $row['kills'];
$display_users .= "<a href=index.php?id=$id>$name</a> &nsbp;$kills<br>";
}
This outputs a result like this :
Bob 3
Rick 1
Tom 0
Dan 2
I've tried a couple things, like this example below :
$sql = "SELECT * FROM users ORDER BY id ASC";
$result = @mysql_query($sql, $connect) or die(mysql_error());
while ($row = mysql_fetch_array($result)) {
$id = $row['id'];
$name = $row['name'];
$kills = $row['kills'];
$killimage = "images/star.gif";
$display_users .= "<a href=index.php?id=$id>$name</a> &nsbp;$killimage<br>";
for ($i=0; $i<$kills; $i++) {
$display_users;
}
}
But when I do that, each user get's an incremental Star image, instead of the number of kills... like this :
Bob *
Rick **
Tom ***
Dan ****
What I want is an output like this :
Bob ***
Rick *
Tom
Dan **
Where am I going wrong with this?
Thanks...