is it possible to reset a counter to 0 while looping through a database?
this script currently loops the database and gets only the first result from each user, and increments the second counter without reseting to 0 on new user.
<?
echo "<BR>";
/////////////////FANTASYBOSS DATABASE FOR TESTING//////////////
mysql_connect("localhost","data1","data1");
mysql_select_db("data1");
$array = array();
$i=0;
$order=0;
$query= mysql_query("SELECT * FROM users");
while ($row = mysql_fetch_assoc($query)) {
$username = $row['username'];
$user= $row['id'];
$pictures= $row['pictures'];
$new= urldecode($pictures);
$array = unserialize($new);
$name= $array[$i]['NAME'];
$description= $array[$i]['DESCRIPTION'];
$file= $array[$i]['FILE'];
$date= $array[$i]['DATE'];
$i++;
$order++;
echo"$date, $description, $user, $file, $order";
echo"<BR>";
// if new username reset $i and $order to 0
}
?>
The desired output will be something like this:
05-21-08, PICTURE OF APPLE, ADMIN, 1
05-21-08, PICTURE OF BALL, ADMIN, 2
05-21-08, PICTURE OF CHAIR, ADMIN, 3
05-21-08, PICTURE OF DOG, ADMIN, 4
05-23-08, PICTURE OF APPLE, JOHN SMITH, 1
05-23-08, PICTURE OF BALL, JOHN SMITH, 2
05-23-08, PICTURE OF APPLE, HARRY JONES, 1
05-23-08, PICTURE OF APPLE, JOHN SMITH, 1
etc etc,
so it will loop through each users data, then once the $user changes, both counters are set to 0.
thanks in advance.