コード例 #1
0
ファイル: example.php プロジェクト: TheProjecter/skeleton
// create a request processor to set pager from GET parameters
#$request = new PagerRequest($pager);
$request = new A_Pager_Request_Session($pager);
$request->process();
if ($pager->hasPages()) {
    // create a HTML writer to output
    $writer = new A_Pager_HTMLWriter($pager);
    // get rows of data
    $start_row = $pager->getStartRow();
    $end_row = $pager->getEndRow();
    $rows = $datasource->getRows($start_row, $end_row);
    // display the data
    echo '<table border="1">';
    echo '<tr>';
    echo '<td>&nbsp;</td>';
    echo '<td>' . $writer->getOrderByLink('id', 'Key') . '</td>';
    echo '<td>' . $writer->getOrderByLink('text', 'Text') . '</td>';
    echo '<td>' . $writer->getOrderByLink('sort', 'Sort') . '</td>';
    echo '<td>&nbsp;</td>';
    echo '</tr>';
    $n = $start_row;
    foreach ($rows as $row) {
        echo '<tr>';
        echo '<td>' . $n++ . '.</td>';
        foreach ($row as $value) {
            echo '<td>' . $value . '</td>';
        }
        echo '<td><a href="example_sub_page.php?script=' . basename($_SERVER['SCRIPT_NAME']) . '">Sub Page</a></td>';
        echo '</tr>';
    }
    echo '</table>';