<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);

$_POST['per2'] = 9;
$_POST['cur2'] = 12;
$_POST['estudiante2'] = 160008;

include '../conector.php';
include 'fpdf.php';

echo "Test con query corregido (per2=9):\n";

$select_periodos="select a.anno,b.periodo,b.id,a.periodo
                from planilla a,planilla b 
                where a.id='".$_POST['per2']."' 
                and a.anno=b.anno
                and b.periodo<a.periodo
                order by b.periodo";

echo "Query: $select_periodos\n\n";

$res = mysql_query($select_periodos);
if(!$res){
    echo "ERROR: " . mysql_error() . "\n";
} else {
    echo "OK - Rows: " . mysql_num_rows($res) . "\n";
}

// Test con per2=10
echo "\nTest con per2=10:\n";
$_POST['per2'] = 10;
$select_periodos2="select a.anno,b.periodo,b.id,a.periodo
                from planilla a,planilla b 
                where a.id='".$_POST['per2']."' 
                and a.anno=b.anno
                and b.periodo<a.periodo
                order by b.periodo";

echo "Query: $select_periodos2\n\n";

$res2 = mysql_query($select_periodos2);
if(!$res2){
    echo "ERROR: " . mysql_error() . "\n";
} else {
    echo "OK - Rows: " . mysql_num_rows($res2) . "\n";
    while($row = mysql_fetch_assoc($res2)){
        print_r($row);
    }
}
?>