FUNKAM35 Posted February 24, 2014 Share Posted February 24, 2014 $total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM rental WHERE $where "),0) ; $total_pages = ceil($total_results/$max_results); if ($total_results > $max_results) { if(!isset($_GET['page'])){ $page = 1; } else { $page2 = $_GET['page']; } $from =(($page * $max_results) - $max_results ); } if($page2>1) { $pages="Page $page2 of $total_pages"; } Hi, I have added the above code and it works fine except I get this error Notice: Undefined Variable $pages I only get this error on page 1 where it doesn't show page 1 of x as I don't want it to show page 1 of x no errors on eg page 2 of x only on page 1 I think because the pages is empty but don't know how to fix this Any help would be appreciated Link to comment https://forums.phpfreaks.com/topic/286474-notice-undefined-variable/ Share on other sites More sharing options...
paddy_fields Posted February 24, 2014 Share Posted February 24, 2014 $total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM rental WHERE $where "),0) ; $total_pages = ceil($total_results/$max_results); if ($total_results > $max_results) { if(!isset($_GET['page'])){ $page = 1; } else { $page2 = $_GET['page']; } $from =(($page * $max_results) - $max_results ); } if($page2>1) { $pages="Page $page2 of $total_pages"; } else { $pages="Page $page of $total_pages"; } Link to comment https://forums.phpfreaks.com/topic/286474-notice-undefined-variable/#findComment-1470399 Share on other sites More sharing options...
FUNKAM35 Posted February 24, 2014 Author Share Posted February 24, 2014 $total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM rental WHERE $where "),0) ; $total_pages = ceil($total_results/$max_results); if ($total_results > $max_results) { if(!isset($_GET['page'])){ $page = 1; } else { $page2 = $_GET['page']; $from =(($page * $max_results) - $max_results ); } if($page>1) { $pages="Page $page of $total_pages"; } else { $pages=""; } } Thanks Paddyfields, this didn't quite work but pointed me in the right direction and this code did work: Link to comment https://forums.phpfreaks.com/topic/286474-notice-undefined-variable/#findComment-1470405 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.