<?php
error_reporting(E_ERROR | E_PARSE);
include '../conector.php';

echo "=== Verificar estructura de planilla ===\n";
$sql = "DESCRIBE planilla";
$res = mysql_query($sql);
while($row = mysql_fetch_assoc($res)){
    echo $row['Field'] . " - " . $row['Type'] . "\n";
}

echo "\n=== Datos en planilla ===\n";
$sql2 = "SELECT id, anno, periodo FROM planilla ORDER BY id";
$res2 = mysql_query($sql2);
while($row2 = mysql_fetch_assoc($res2)){
    echo "ID: " . $row2['id'] . ", Año: " . $row2['anno'] . ", Periodo: " . $row2['periodo'] . "\n";
}

echo "\n=== Test query con todos los campos ===\n";
$select_periodos="select a.anno as a_anno, a.periodo as a_periodo, b.periodo as b_periodo, b.id as b_id
                from planilla a, planilla b 
                where a.id=9 
                and a.anno=b.anno
                and b.periodo < a.periodo
                order by b.periodo";

$res = mysql_query($select_periodos);
echo "Resultados: " . mysql_num_rows($res) . "\n";
while($row = mysql_fetch_assoc($res)){
    print_r($row);
}
?>