There is no reason to do this with frames, really. This is the time to start delving into the world of databases. The standard for most people at this stage seems to be MySql for database usage (as most hosts offer it and it is easy to find php code to tie into it).
Instead of hard-coding each section into a separate page and using a switch or an array to choose the correct page to jam into an iframe, what you will want to do is store the raw information (without the markup) in a database. Then your php page will have a script to read the $_GET variable, query the database for entries in that category, handle any errors (what if the category requested does not exist?), and format/present the results into HTML markup in the page.
So for the first step, you need to see what's in the $_GET variable. Always always ALWAYS sanitize input received from the user. I won't go into detail about why, other than to suggest that you read up on "MySql injection attacks" for a primer on why this is such a must.
So, you will retrieve the $_GET value for the product category, sanitize it (with a whitelist you can pull from your database, for one idea), and act on it.
Assuming the category requested is a real category, you proceed to the next step...
Suppose the user selected "motorBicycling" and that your "motorBicycling" category has 7,000 products in it. You won't want to even try to display them all at once, so you will query your database with a "LIMIT" of, say, 20 results. Assuming your database of products has all information in a single table (which it probably shouldn't, but we're dealing with a simple case and this takes some of the confusion out of it) that might look something like this:
Code:
SELECT * FROM products WHERE category='motorBicycling' ORDER BY product_name ASC LIMIT 0, 20
This queries your "products" table to find all information about results whose category is listed as "motorBicycling." It arranges ("ORDER BY") the results in ascending ("ASC") alphabetical order by the product's name,
and then cuts off the results from result #0 through result #19 ("LIMIT 0, 20" - remember since we start counting at zero, we end at 19 after getting 20 records). This will allow you to present "pages" of results. For example, if the above was the query for page 1, the query for page 2 would be:
Code:
SELECT * FROM products WHERE category='motorBicycling' ORDER BY product_name ASC LIMIT 20, 20
The first number after "LIMIT" is the record number to start with and the second number is the number of results to pull.
Now, assuming we have a result set of 20 items and their relevant product information, we set up a loop to print formatted HTML to the existing page (using this as "products.php"):
PHP Code:
<!doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<title>Product Page Example</title>
<link type="image/x-icon" href="/favicon.ico" rel="shortcut icon" />
<link rel="stylesheet" href="/style.css" media="all" />
<link rel="stylesheet" href="/print.css" media="print" />
<style type="text/css">
</style>
<body>
<?php
# Retrieve and sanitize the category...using "static" whitelisting here for simplicity of the example...
# This isn't "santization" in the classic sense, but it does ensure only an approved string is used for the query...
$category = $_GET['page'];
$valid_categories = array(
"motorBicycle",
"TYJBowstrings",
"airplanes"
);
$products = array(); # Set this up for array_push to use next...
if(in_array($category,$valid_categories)){
# If the category requested is valid, we connect to the DB and run the query...
$db_user = "username_here";
$db_pw = "password_here";
$db_name = "db_name_here";
$conn = mysql_connect("localhost",$db_user,$db_pw);
if($conn){
if(mysql_select_db($db_name)){
$query="SELECT * FROM products WHERE category='$category' ORDER BY product_name ASC LIMIT 0, 20"; # Note that in this line, if presenting a user with pages of results you will need to add logic to change the starting entry number from "0" to whatever is appropriate...
$result = mysql_query($query);
while($row = mysql_fetch_assoc($result)){
array_push($products,$row);
}
}
mysql_close($conn);
}
if(count($products)>0){
# If we have one or more results, format and output the product information for each result... The example here uses a simple table, but the basic idea is the same regardless of your desired type of HTML markup...
print "<table><thead><tr><th>Product</th><th>Price</th><th>Quantity Available</th></tr></thead><tbody>";
for($i=0;$i<count($products);$i++){
print "<tr><td>".$products[$i]['product_name']."</td><td>".$products[$i]['unit_price']."</td><td>".$products[$i]['stock_quantity']."</td></tr>";
}
print "</tbody></table>";
}
else{
# If there are no results, display a message to the user...
print "<p>Sorry, no results were found for your request...</p>";
}
}
else{
# If category was bogus, we let the user know...
print "<p>Invalid category, please try again...</p>";
}
?>
</body>
</html>