Wednesday, April 29, 2009

template auto run script

<?php

$startRow = 0;
$rowPerPage = 10;
$totalRow = 111;


$runCycle = (int)($totalRow / $rowPerPage);

run_yahoo($startRow, $rowPerPage, $totalRow);

function run_yahoo($startRow, $rowPerPage, $totalRow) {
$runCycle = (int)($totalRow / $rowPerPage);

if (($totalRow % $rowPerPage) != 0) {
$runCycle++;
}

$nextStartRow = NULL;

for ($i = 0; $i < $runCycle; $i++) {
$nextStartRow = $nextStartRow ? $nextStartRow : $startRow;
$nextStartRow = _get_yahoo_data($nextStartRow, $rowPerPage, $totalRow);
}
}

function _get_yahoo_data($startRow, $rowPerPage, $totalRow) {
$nextStartRow = $startRow + $rowPerPage;
echo 'LIMIT ' . $startRow . ', ' . $nextStartRow . '
';

return $nextStartRow;
}

?>

No comments: