PHP: How to save in session generated table, and apear everytime when curent user is login?

This is table, who is generated when user pick some values in select boxes.
How to save in session this generated table, and appear every time when current user is login.

  <table border="0" class="table table-hover table-striped" name="raspored" id="raspored" class="tablesorter">
        	<thead>
        <tr COLSPAN=2 BGCOLOR="#6D8FFF">
            <th>ИД</th>
            <th>Предмет</th>
            <th>Професор</th>
    		<th>Ден</th>
    		<th>Час</th>
    		<th>Просторија</th>
    		<th>Тип</th>
        </tr>
    	</thead>
    	
        <?php
        foreach ($_POST['predmet'] as $predmet) {
    		$_SESSION['predmet'] = $_POST['predmet'];
            $rows = get_info($db, $predmet);
            if (count($rows)){
                foreach ($rows as $row) {    	
    		$_SESSION['row'] = $rows;
                echo "<tr>" .
                    "<td>" . $row["ID"] . "</td>" .
                    "<td>" . $row["predmet"] . "</td>" .
                    "<td>" . $row["profesor"] . "</td>" .
    				"<td>" . $row["den"] . "</td>" .
    				"<td>" . $row["chas"] . "</td>" .
    				"<td>" . $row["prostorija"] . "</td>" .
    				"<td>" . $row["tip"] . "</td>" .
                    "</tr>";
    			}
            }	
    	}
    		
    	
    		
        ?>
    	
    </table>

I thought I answered the same question in your previous thread…

Not working properly. I trying with this but on logout table disapear.

<?php
session_start();
if ($_SESSION['table_stored_in_session']) {
    echo $_SESSION['table_stored_in_session'];
} else {
        ob_start();
    ?>
    <table border="0" class="table table-hover table-striped" name="raspored" id="raspored" class="tablesorter">
        <thead>
            <tr COLSPAN=2 BGCOLOR="#6D8FFF">
                <th>??</th>
                <th>???????</th>
                <th>????????</th>
                <th>???</th>
                <th>???</th>
                <th>??????????</th>
                <th>???</th>
            </tr>
        </thead>
        <?php
        foreach ($_POST['predmet'] as $predmet) {
            $_SESSION['predmet'] = $_POST['predmet'];
            $rows = get_info($db, $predmet);
            if (count($rows)){
                foreach ($rows as $row) {       
                    $_SESSION['row'] = $rows;
                    echo "<tr>" .
                        "<td>" . $row["ID"] . "</td>" .
                        "<td>" . $row["predmet"] . "</td>" .
                        "<td>" . $row["profesor"] . "</td>" .
                        "<td>" . $row["den"] . "</td>" .
                        "<td>" . $row["chas"] . "</td>" .
                        "<td>" . $row["prostorija"] . "</td>" .
                        "<td>" . $row["tip"] . "</td>" .
                        "</tr>";
                }
            }   
        }
        ?>
    </table>
    <?php
    $table = ob_get_clean();
    $_SESSION['table_stored_in_session'] = $table;
    echo $table;
}
?>

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.