Jump to content

Coding issue with post/get and isset and Pagination -- PLEASE help! :)


Jax2

Recommended Posts

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

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.

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'];

 

:o

 

Now I feel like schmuck.

 

It works brilliantly now. Hoorah!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.