views:

102

answers:

2

Hi,

i have a simple grid with data from mysql db.

When delete a record actually refresh the page.

When i am at last page and start delete records after delete all records when refresh i get no data because i dont have any records on that page.

So some how i must find a way when i am on last page and all record deleted refresh to previous page.

Any ideas

thanks

+1  A: 

Do a simple count on the rows to be displayed.

if ($row_count == 0)
    ... redirect to previous page

make sure you allow for there actually being no records to be displayed on the first page.

Derek Organ
+1  A: 

in your code where you get the current page, compare it to the max pages

$currentPage = (int) $_GET['page'];
$currentPage = ($currentPage <= $maxPages) ? $currentPage : $maxPages;
solomongaby
if($currentPage > $numOfPages){ header("Location: ?p=$numOfPages"); }That did the trick.Thanks
ntan