PDA

View Full Version : File Path Extension Query...?



e1seix
07-09-2007, 10:26 PM
Complete php novice here, as you're about to find out.

Am constructing a rather large database-based product website.

If my imaginary page is: 'http://mydomain.com/index.php' I'm looking for the code I would place in the index.php file in order for the following link ('http://mydomain.com/index.php?Brand=Adidas&ProductID=Trainers') to narrow down the info called from the mySQL database and display all corresponding products and associated column info in a table (can juggle the table display bit).

I'd imagine it's some sort of loop and "if" statement, although that would be a lot of coding to do for so many products.

I just need the connection as even now if I type 'http://mydomain.com/index.php?Brand=Adidas&ProductID=Trainers' into the address bar, it returns the contents of 'http://mydomain.com/index.php'

Does that make sense... stuck! Help! I wouldn't even know what to put in the search bar in google to get the results i want

Much obliged...

djr33
07-09-2007, 10:47 PM
First, a very basic example:
<?php
if (isset($_GET['Brand'])) { include('brandpage.php'; } //if there is a brand, include that script
else { include('main.php'; } //else, include the main (index) script
?>

Now, that will allow you to output two pages in one. You could also, rather than using includes, just put the entire page of html there, and surround it with the brackets {}.
That might be a bit harder to organize.

Anyway, all you need to do to check that is use if statements and search the database.
if (isset($_GET['Brand'])) { do_mysql_query, etc. }

You'll first want to decide if the get variables are valid for finding a product. If so, then just search the database for them. If not, output the main page.

If you need help with php/mysql, use this tutorial:
http://php-mysql-tutorial.com

e1seix
07-10-2007, 05:23 PM
hmmm... works pretty well. does exactly what it says on the tin, but there's a problem.

http://www.dogfightuk.com/browse.php?BrandID=AME&product_sku=2206

"2206" is a unique column entry to a particular brand that should display two results. However, one of these results also shares another's column data with a second brand, "2207."

Because in a few of my table results I use this other shared data 'CAT=fragrance' to fill the results, I'm getting repetitive results from both

http://www.dogfightuk.com/browse.php?BrandID=AME&product_sku=2206 &
http://www.dogfightuk.com/browse.php?BrandID=ANG&product_sku=2207

Is there a way that if I run the first one it will automatically disregard any other data that does not have 'BrandID=AME' and 'product_sku=2206.'

I used that first example where http://www.dogfightuk.com/browse.php?BrandID=AME&product_sku=2206 loads another page, which loads the data.