문제

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