gwynn_aaron wrote in php

More PHP help is begged for

Yeah, it's me again. Seems like each time a problem gets worked on and solved a new one crops up to take its place. In this case there are two that I'm now having. The relevant page to view is here: products.php.

The pieces of code that you'll need to see can be found in these documents:
_formatting.txt
products_displayBrand.txt
products_displayProduct.txt

The first one is a file which gets included in all of the pages while the other two are the pages themselves.

First problem — SOLVED

On the left side of the page you'll see a number of links. If you were to click on the first one you would go to a product family page. If you were to click on the second one you would end up on the index page of the site, which is a built in fail-safe if there is something wrong with the page you are looking at, only there shouldn't be.

Here's what should be happening. The variable 'brand_id' should be getting pulled from the table 'brands' and used for the first five links on the page. There are five records in that table with ids 1 through 5. Number 1 seems to be working properly, but if it were then the following four would be as well. Here's what seems to be going wrong. Rather than using the 'brand_id' found in 'brands' to display the proper record from 'brands' it seems to be using the variable 'brand_id' as pulled from the table 'products'. In the case of the first brand this works because there are two records in 'products' both with their brand id set to 1. But since there are no records belonging to the other brands yet the other links are breaking.

So what I need to know how to do is tell the code that for the purpose of those main links it should be using the 'brand_id' from 'brands' and not from 'products'.

Second problem — SOLVED

From the page products.php click on the first [blue] link, which should take you to products_displayBrand.php?brand_id=1. Immediately below the link you just clicked on you'll see that there are now two, light blue links. Now click on one of those light blue links and you'll see a new page and they will have disappeared. They should not do that.

To see what I've done with this you need to look mainly in _formatting.txt, beginning around line 126. 126 to 140 sets up the code which pulls information from the table 'products' and creates the appropriate links. Then from line 142 to 176 I've set up if-else statements which use 'brand_id' to determine whether or not to display the sub-links for that brand. This is working for the first brand and I think it will work for the others (though I can't check yet because of problem one from above). I think this is all working because when you go to the brand page (products_displayBrand.php) 'brand_id' is passed as a variable in the URL, which allows it to be used for the if-else statement. I think it is not working with the subsequent page (products_displayProduct.php) because 'brand_id' is no longer being passed in the URL, having been replaced with 'product_id'.

What I need to know, now, is if there is a way to make 'brand_id' carry-over to the second page so that the sub-links continue to appear.


New problem

From the page products.php click on the first [blue] link, which should take you to products_displayBrand.php?brand_id=1. Immediately below the link you just clicked on you'll see that there are now two, light blue links. Now click on one of those light blue links and you'll see a new page. This is all as it should be, but what is not is that clicking on either link pulls the same information from the database, rather than two different sets. This may not be readily apparent, but if you look at the name of the product you'll see that both links take you to the information for Mix #2. So what I need help figuring out is how to get these links behaving right--as in drawing the correct information from the database based on their unique product_ids.

Pleading

Please have a look at my problems and what I've done so far. I've spent the last seven days working on all of this and my boss is starting to get antsy. I need to try to have these problems worked out as soon as possible and I've exhausted my knowledge of PHP to get to where I am now. Thank you.