For starters; your code is ripe for a vulnerability known as SQL Injection
, which was identified well over 20 years ago...
create an SQL command by string together together command text with user input- there is plenty of documentation on how to do add user content to a query
$stmt = $mysqli->prepare("SELECT username FROM attendance_student WHERE semester_class=?");
$stmt->bind_param("s", $_POST['name'], $semester_class);
$result = $stmt->get_result();
PHP: Prepared Statements - Manual
PHP MySQLi Prepared Statements Tutorial to Prevent SQL Injection