smithmr8 Posted July 8, 2010 Share Posted July 8, 2010 Hi, http://www.bytefish.co.uk/client_DFC/products.php?page=1&sort=B Trying to get it to list the items which begin with the letter B. It does this to some degree. However, as you get a couple pages into it it keeps displaying the same data. Here is the PHP: if($_GET['sort'] == ""){ $all = mysql_num_rows(mysql_query("SELECT * FROM `products`")); } else { $sort = $_GET['sort']; $all = mysql_num_rows(mysql_query("SELECT * FROM `products` WHERE `name` LIKE '$sort%'")); echo $all; } if ($all % 50 != 0){ $remainder = ($all - ($all % 50)); $total = ($remainder / 50)+1; } else { $total = ($all / 50); } if ($_GET['page'] > 0){ $page = $_GET['page']; } else { $page = 1; } $upper = $page * 50; $lower = ($page - 1) * 50; if($_GET['sort'] == ""){ $products = mysql_query("SELECT * FROM `products` LIMIT $upper, $lower"); } else { echo $lower; echo $upper; $products = mysql_query("SELECT * FROM `products` WHERE `name` LIKE '$sort%' LIMIT $lower, $upper"); } Any ideas ? Link to comment https://forums.phpfreaks.com/topic/207180-duplicate-data-in-output/ Share on other sites More sharing options...
smithmr8 Posted July 8, 2010 Author Share Posted July 8, 2010 Seems to start doing so on page 5 for me. Not "IODINE" is continually listed as the last item in the table on the remaining pages, as does the other items. Not quite sure why. Link to comment https://forums.phpfreaks.com/topic/207180-duplicate-data-in-output/#findComment-1083263 Share on other sites More sharing options...
smithmr8 Posted July 8, 2010 Author Share Posted July 8, 2010 Solved. lol. Did this instead.. //$upper = $page * 50; $lower = ($page - 1) * 50; if($_GET['sort'] == ""){ $products = mysql_query("SELECT * FROM `products` LIMIT $lower, 50"); } else { echo $lower; echo $upper; $products = mysql_query("SELECT * FROM `products` WHERE `name` LIKE '$sort%' LIMIT $lower, 50"); } Link to comment https://forums.phpfreaks.com/topic/207180-duplicate-data-in-output/#findComment-1083266 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.