So put your $_POST['predmet1']
into the session when it is set.
And change the condition to check session as well:
// check POST and SESSION
if (isset($_POST['predmet1']) || isset($_SESSION['predmet1'])) {
// get ID from POST or SESSION
$predmet1 = isset($_POST['predmet1']) ? $_POST['predmet1'] : $_SESSION['predmet1'];
// and store it into the session
$_SESSION['predmet1'] = $predmet1;
// get rows
$rows = get_info($db, $predmet1);
// ... the rest of the code ...