This is due to you adding to an array. Since $gens[] is appending on each iteration of $genres, and then within each iteration of $genres it iterates $gens, it will just grow as each record goes through. Lets say you have three records of $genres, 'pop', 'rock', 'jazz' in that order. The iterations of the while would leave the $v in the following states:
- pop,
- pop, pop, rock
- pop, pop, rock, pop, rock, jazz,
So if I had to guess what you are looking for, it is this:
PHP Code:
while ($t = mysql_fetch_assoc($genres))
{
$gens[] = $t['gen_name'];
}
$v = implode(', ', $gens);
// or
$i = 0;
$v = '';
while ($t = mysql_fetch_assoc($genres))
{
if ($i++ > 0)
{
$v .= ', ';
}
$v .= $t['gen_name'];
}
Both of which should result in $v being 'pop, rock, jazz' if I didn't biff it.