I am working on a PHP page that shows a table with query results. I want 2 buttons, with 'next' and 'previous', which change a variable used in this query:

SELECT les.lesuur, les.clustercode, les.lokaal, les.leraar, les.status 
FROM les, zitin 
WHERE zitin.leerlingnummer='$dimGebruiker' 
    AND zitin.clustercode=les.clustercode 
    AND les.dag='$huidigedag' 
ORDER BY les.lesuur

$huidigedag is the one that should be changed. This is what I have in the beginning of the PHP code:

session_start();
if (!isset($_SESSION["huidigedag"])){
    $_SESSION["huidigedag"] = 1;
}
$huidigedag = $_SESSION["huidigedag"];

Then, I added a link to the two buttons (arrow images):

<a href="volgende.php">

(volgende means next)

This is volgende.php:

<?php 
    $_SESSION["huidigedag"] = $_SESSION["huidigedag"] + 1;
    header("location:leerlingrooster.php");
?>

However, when I click the button, nothing happens. I echo'd $huidigedag, and noticed it stayed on 1, without changing.

有帮助吗?

解决方案

try to add session_start() to the beginning of volgende.php

其他提示

I would change volgende.php to:

<?php 
   session_start();
   $_SESSION["huidigedag"] = (!isset($_SESSION["huidigedag"])) ? 1 : ($_SESSION["huidigedag"] + 1);
   header("location:leerlingrooster.php");
   exit;
?>
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top