php - How to get the right max id and min id from a function? -
php - How to get the right max id and min id from a function? -
i had big table 3 1000000 rows before, split 6 tables 500.000 rows each, i'm trying connect them, want read 1 table 1 not 6 tables @ same time, i'm trying utilize website pagination select table needs read , max id , min id.
i made function:
$content['data']['max_table'] = 6; $content['data']['min_table'] = 1; $content['data']['limit_page'] = 100; function tables( $start_num, $end_num ) { global $content; if($end_num <= 500000) { $table_number = $content['data']['max_table']; } else if($end_num > 500000) { $calc = intval($end_num/500000); $table_number = $content['data']['max_table']-$calc; } $array = array(); $array['table_number'] = $table_number; $array['max_id'] = ($table_number*500000)-$end_num; $array['min_id'] = ($array['max_id']-$content['data']['limit_page'])-$start_num; homecoming $array; }
this function gives me right table_number, max_id , min_id wrong.
page limit 100, if page number 1 = $start_num 1 , $end_num 100 , table_number 6 here max_id needs 3000000 , min_id need 2999900
if page number 5000 = $start_num 499901 , $end_num 500000 , table_number 6 here max_id needs 2500101 , min_id need 2500001
if page number 5001 = $start_num 500001 , $end_num 500100 , table_number 5 here max_id needs 2500000 , min_id need 2499900
...
i want show via order id desc
table 6: max id = 3000000 min id = 2500001 table 5: max id = 2500000 min id = 2000001
how can right max_id , min_id function can select right way?
try this:
$array['min_id'] = 6 * 500000 - $end_num + 1; $array['max_id'] = $array['min_id'] + 99;
php mysql
Comments
Post a Comment