Jax2 Posted March 22, 2010 Share Posted March 22, 2010 Hello everyone. I am having an issue here. Let me try and explain how my page is set up so you understand better. I have: INDEX.PHP RECIPES.PHP My index.php basically consists of the header, login stuff, a main page section that changes depending on which link you choose using the GET method (i.e. index.php?action=users or index.php?action=recipes ...etc) Now, on my recipe.php I have a few different sections determined by using isset 's For example: if (isset['add'] { add recipe code } ELSE if (isset['browse'] { browse by category code } ELSE { Show all recipes }; That is the basic idea here. I have added pagination to the browse all records. The default works fine. It finds all the records and returns them and the previous and next buttons as it's supposed to, with the links set up like this: <a href='index.php?currentpage=$totalpages&action=recipes'> >> </a> It returns to index.php?action=recipes and shows me the next page correctly. Where I am running into trouble is when I'm trying to add pagination to the browse by category section of recipes.php. I have tried setting the links to look like this: <a href='index.php?currentpage=$totalpages&action=recipes&do=browse'> >> </a> And I tried setting the browse by categories like this: if (isset($_POST['browse']) || $_GET['do']=="browse") { Which I thought would be the exact same as: if POST (browse) is set OR if GET (do) = browse, do this: When I click on browse by category, it shows me the first 5 records just fine, as well as a page 1 of 3 and the "next" link. When I click on the link, nothing shows up, which I can only assume means that it's not finding the right section of my code. I am further assuming this is due to the line: if (isset($_POST['browse']) || $_GET['do']=="browse") { Could someone please tell me what I need to do to make this work, or if more information is needed, please ask. I'm desperately in need of fixing this today if possible. Thank you so much in advance! Jax2 Link to comment https://forums.phpfreaks.com/topic/196183-coding-issue-with-postget-and-isset-and-pagination-please-help/ Share on other sites More sharing options...
Jax2 Posted March 22, 2010 Author Share Posted March 22, 2010 I guess my actual question is this: How can I run a block of code based both on a form using a submit button with the name "browse" (I.e. $_POST['browse']) OR a text link using the get method (I.e. $_GET['do']=="browse") ... Link to comment https://forums.phpfreaks.com/topic/196183-coding-issue-with-postget-and-isset-and-pagination-please-help/#findComment-1030260 Share on other sites More sharing options...
andrewgauger Posted March 22, 2010 Share Posted March 22, 2010 I think the fact that you get nothing back is actually due to an error inside your block of code. The example: if(isset($_POST["browse"]) || $_GET['do'] == "browse") is perfectly valid. I've mixed post and get behaviors to have different responses depending on how the message was sent. I think you might have a missing ; somewhere in your block of code (or some other logic problem). Try and show more of that function, or at least put a echo "script works"; at the end to rule out my advice. Link to comment https://forums.phpfreaks.com/topic/196183-coding-issue-with-postget-and-isset-and-pagination-please-help/#findComment-1030266 Share on other sites More sharing options...
Jax2 Posted March 23, 2010 Author Share Posted March 23, 2010 You know, I've been having a lot of these duh moments lately. I originally was going to post my code here, and I went through to clean it up a bit. I found this: $ID=$_REQUEST['ID']; and then about 8 lines down, I found this: $ID=$_POST['ID']; Now I feel like schmuck. It works brilliantly now. Hoorah! Link to comment https://forums.phpfreaks.com/topic/196183-coding-issue-with-postget-and-isset-and-pagination-please-help/#findComment-1030274 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.