I made a master/detail form using adodb-pager.inc.php.
I have an initial form where the user posts the id of the product he wants to see the details. It works just fine, but when the user presses the button "next" to see the next results related to the very same product, it gives an error. I think its because it looses the values of the variables posted by the user. Can anyone help me? Thanks
<?php
//SCRIPT: do-list-career.php
require_once("c:\web\adodb\adodb.inc.php");
require_once("c:\web\adodb\adodb-pager.inc.php");
require_once("my-functions.inc");
session_start();
include("header.php");
echo "<h2>Teacher career evolution</h2>";
//check session variable
//echo "VALID USER: $_SESSION[valid_user]<br>";
if ($_SESSION["valid_user"])
{
$SESSION["$teacher_id"] = $POST["teacher_id"];
//this cames from a form
//echo "$_POST[teacher_id]<br>";
//Lets connect to db
$db = NewADOConnection('postgres');
$db->debug = true;
$db->connect("host=localhost
port=5555
dbname=test
user=test_user
password=1234") or die("unable to connect");
$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
$rsSel = $db->Execute ("Select t.name,t.teacher_id
from teacher t, career c
where t.teacher_id=c.id_teacher and t.teacher_id= $_SESSION[teacher_id]");
$name = $rsSel->fields[0];
$teacher_id = $rsSel->fields[1];
echo "<table border = 1 width=30% BORDERCOLOR=white>";
echo "<table border = 1 width=30% BORDERCOLOR=white>";
echo "<tr><td><b>ID:</b></td>";
echo "<td>$teacher_id</td></tr>";
echo "<tr><td><b>Name:</b></td>";
echo "<td>$name </td></tr>";
echo "<tr><td>";
echo "</table>";
//sql query to be executed
$sql = "select c.date, c.id_category ,c.id_type_Contract from teacher t, career c
where t.teacher_id=c.id_teacher and t.teacher_id= $_POST[teacher_id] order by c.date";
//echo "$sql<br>";
$pager = new ADODB_Pager($db, $sql);
$pager->Render($rows_per_page=2);
//Disconnect DB
$db->close();
}
else
{
echo "<p>You are not logged in.</p>";
echo "<p>Only logged in members may see this page.</p>";
}
echo "<a href=\"members_only.php\">Pag. dos membros</a>";
?>