smithmr8 Posted July 7, 2010 Share Posted July 7, 2010 Hi, I'm trying to get a page system together for displaying items from a DB. $page = $_GET['page']; $upper = ($page - 1)*50; $lower = $page * 50; echo "Page:".$page."<br />"; echo "Lower:".$lower."<br />"; echo "Upper:".$upper."<br />"; The above is the code I am using. I am going to a page, ie. products.php?page=1 This gives the page variable the value of 1, which will display when echo'd. However, if I try to perform any operations on it, it displays nothing. $lower needs to be equal to the value of $page - 1 * 50 $upper needs to be equal to the value of $page * 50 But I cant get it to do this. Any ideas ? Link to comment https://forums.phpfreaks.com/topic/207075-variable-operations/ Share on other sites More sharing options...
smithmr8 Posted July 7, 2010 Author Share Posted July 7, 2010 Was just being a tad dumb. Haven't done much PHP in a long time. hehe Link to comment https://forums.phpfreaks.com/topic/207075-variable-operations/#findComment-1082764 Share on other sites More sharing options...
ChemicalBliss Posted July 7, 2010 Share Posted July 7, 2010 I would add an isset() and is_numerical on that page variable to make a default value: $page = (isset($_GET['page']) && is_numerical($_GET['page']))? $_GET['page'] : 1; $upper = ($page - 1)*50; $lower = $page * 50; echo "Page:".$page."<br />"; echo "Lower:".$lower."<br />"; echo "Upper:".$upper."<br />"; -cb- Link to comment https://forums.phpfreaks.com/topic/207075-variable-operations/#findComment-1082765 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.