I am trying to built a search page for products in which i have two table products and inventory, i have my product details in product and inventory details like color,size,pric
You can catch values from an url. you can use " $_GET['parameter'] "
$color = $_GET['color'];
$category = $_GET['cat'];
using PDO, something like -
$dbh = new PDO(...)
$sth = $dbh->prepare('SELECT p.product_name, p.product_sku, p.product_desc, i.inventory_color
FROM products as p
INNER JOIN invetory as i ON p.product_id = i.product_id
WHERE p.cat = ? AND i.inventory_color = ?');
$sth->execute(array($_GET['cat'], $_GET['color']));
$results = $sth->fetchAll();
from example at http://www.php.net/manual/en/pdo.prepare.php
You can get it with $_GET like:
$product_id = $_GET['product_id'];
Yes, you are in the right path. Get the values from url using get
or request
$category=mysql_real_escape_string($_GET['cat']);
$color=mysql_real_escape_string($_GET['color']);
and make your SQL as
SQL="SELECT p.product_name, p.product_sku, p.product_desc, i.inventory_color, i.inventory_size
FROM products as p
INNER JOIN invetory as i ON p.product_id = i.product_id
WHERE p.product_category='".$category."' AND i.inventory_color='".$color."'";