I'm fetching an array of numbers from my database, and printing the array out, but it's only returning the value at index of 0, even though the other indexes has values too, and all their playerName is set to $username. Please help. Thanks.
<?php
session_start();
$username = $_SESSION['username'];
$fetch = mysql_query("SELECT amount FROM playerDeck WHERE playerName = '$username'");
$count = mysql_num_rows($fetch);
$fetch = mysql_fetch_array(mysql_query("SELECT amount FROM playerDeck WHERE playerName = '$username'"));
while($count > 0){
$count--;
echo "$count";
echo "fetch$fetch[$count]</br>";
?>
Results:
13fetch
12fetch
11fetch
10fetch
9fetch
8fetch
7fetch
6fetch
5fetch
4fetch
3fetch
2fetch
1fetch
0fetch1
The array with index of 0 returns the number 1, but the array with the index of other numbers return with the value null, even though there are numbers in the table inside the database with the username set to $username.