会话数组只回显最后一个元素[关闭]

I have my session variable store array:

$outputs = array();
while($row = mysql_fetch_array($query))
{

    $_SESSION['row_id'] = $row['id'];
    $outputs = $row['sport_ime'].' '.$row['sezona'].'<a href=../view/modifikacije.php> Edit</a><br>';
    $_SESSION['output'] = $outputs;

}

And then on another page I call that variable:

$outputs = $_SESSION['output'];
echo ($outputs); 

It just echoes one row. It is the last entry in my database.

Why doesn't it echo everything?

Try this

$_SESSION['row_id'][] = $row['id'];
$_SESSION['output'][] = $outputs;

Please read about PHP arrays, and generally consult the manual when you're stuck.

You overwriting same session id. Use like this:

while($row = mysql_fetch_array($query))
{
    $outputs = $row['sport_ime'].' '.$row['sezona'].'<a href=../view/modifikacije.php> Edit</a><br>';
    $_SESSION[$row['id']] = $outputs;
}

Echo it:

$id = 5;
echo $_SESSION[$id]; // your output

Note: I advice that you should use function have return array