What would be the best and simpliest way to do this in PHP?
I have 3 database tables linked to each other.
The table Teacher has the following fields: teacher_id, name, address, city, phone_number.
The table Career has the following fields: teacher_id, date, profissional_category.
The table Prof_category : cat_id,category
I'd like to make a master/detail showing the career evolution of a teacher with the following fields (for example):
teacher_id - 1000
name - Carol Baker
date | profissional_category
01-01-2000 | monitor junior
01-01-2001 | monitor senior
01-01-2003 | monitor senior A
Thanks
<?php
//SCRIPT: list-hist.php
require_once("c:\web\adodb\adodb.inc.php");
require_once("my-functions.inc");
session_start();
include("header.php");
echo "<h2>Career Evolution</h2>";
//check session variable
//echo "VALID USER: $_SESSION[valid_user]<br>";
if ($_SESSION["valid_user"])
{
//This cames from a previous form
//echo "$_POST[nmec]<br>";
//Connect to the database
$db = NewADOConnection('postgres');
//$db->debug = true;
$db->connect("host=localhost
port=5222
dbname=test
user=test_user
password=1234") or die("Cannot connect");
$rsSel = $db->Execute ("Select t.name,t.teacher_id
from teacher t, career c
where t.teacher_id=c.id_teacher and c.id_teacher= $_POST[id_teacher]");
$name = $rsSel->fields[0];
$teacher_id = $rsSel->fields[1];
echo "<table border = 1 width=50% bgcolor=#fff5ee BORDERCOLOR=white>";
echo "<table border = 1 width=50% bgcolor=#fff5ee BORDERCOLOR=white>";
echo "<tr><td><b>Teacher Cod:</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>";
$rsSel1 = $db->Execute ("Select c.date,c.professional_category from teacher t, career c
where t.teacher_id =c.id_teacher and c.id_teacher= $_POST[id_teacher]");
while (!$rsSel1->EOF){
print_r($rsSel1->fields);
$rsSel1->MoveNext();
}
$date = $rsSel1->fields[0];
$professional_category = $rsSel1->fields[1];
echo "<table border = 1 width=50% bgcolor=#fff5ee BORDERCOLOR=white>";
echo "<table border = 1 width=50% bgcolor=#fff5ee BORDERCOLOR=white>";
echo "<tr><td><b>Date:</b></td>";
echo "<td>$date</td></tr>";
echo "<tr><td><b>Prof. Category:</b></td>";
echo "<td>$professional_category </td></tr>";
echo "<tr><td>";
echo "</table>";
//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\">Members Page</a>";
?>
I'd like to be shown in a table, and I think it will be needed a button to the next and previous recordset...