Php foreach possibly?

Okay so i have a database with items from a game im working on, and there is a column called “class”, this contains the different item types (sword,axe,bow) etc… i was wondering if anyone could help me out? i want so it creates a button for each class…what i’m doing is making an armory for the item database,and so i wanted like it to create a button for each class? because right now i create like 12 buttons on my own and linked them to separate pages, and every time we add a new item class i have to go in and make new buttons

$table = 'name_your_table';
$query = "SELECT * FROM $table GROUP BY `class` "

$result = mysql_query($query);
while(($record = mysql_fetch_assoc($result)) !== false){
  echo '<a href="index.php?class='.$record['class'].'">'.$record['class'].'</a>';


for some reason its only selecting one class…“Shoulder”

nevermind i got it working thanks so much