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

echo "Test query with per2=10 (periodo 2):\n";

$select_periodos="select a.anno,b.periodo,b.id,a.periodo
                from planilla a,planilla b 
                where a.id=10 
                and a.anno=b.anno
                and b.periodo<a.periodo
                order by b.periodo";

echo $select_periodos . "\n\n";

$res = mysql_query($select_periodos);
if(!$res){
    echo "Error: " . mysql_error() . "\n";
} else {
    while($row = mysql_fetch_assoc($res)){
        print_r($row);
    }
}
?>