I am trying to query mysql via PHP to get a list of class names from a table. I then want the user to click on one of these class names to be redirected to a page which displays the class roster for whatever class was clicked on. The rosters are generated on-the-fly from another table in the database, right now I'd like to just save the class name as a session variable, then have the roster.php page use that variable to query for the correct roster. 

ex.)

class a -click-> roster.php 

-> `echo (// roster 'a' as <ol> from table);`

class b -click-> roster.php 

-> `echo (// roster 'b' as <ol> from table);`

class a -click-> roster.php 

-> `echo (// roster 'c' as <ol> from table);`

I understand how to query and how to echo out html lists through a php page, **but I'm not sure how I would generate buttons for the class names, then have the webpage track which button is clicked on.** 

Here is the code I have written to generate the rosters from the database.

```
$sql = "SELECT firstname, lastname FROM student_Data WHERE classs =" . $_SESSION['classname'];
$result = $conn->query($sql);

if ($result->num_rows > 0) {
     // output data of each row
     echo("<div id=\"list1\">")
     while($row = $result->fetch_assoc()) {
         echo ("<li><h4 class=\"list-group-item-heading\">". $row["firstname"]. " " . $row["lastname"] . "</h4></li>");
     }
     echo("</div>");
} else {
     echo ("");
}

```

*Side note*: This is a personal project so I rather produce quick code over efficient code. Which is why I am OK with session vars.