I am trying to produce a shopping site where I am selling items that fluctuate in price daily (precious metals). I have a table (products) that will contain a multiplier (something like "1.1") for each product. I basically don't want to have to go into my tables and change the prices of hundreds of items every day. My idea is to create another table where I will simply change the price field with the daily value each day. How can I make the final product price total the multiplier from one table multiplied by the entered daily price from another table. Or, is there a better way than using two tables? Here's the coding so far using just one table with a defined price :
if (isset($_GET['id'])) {
//Connect To Mysql Database
include"storescripts/connect_to_mysql.php";
$id = preg_replace('#[^0-9]#i','',$_GET['id']);
//Use This VAR To Check To See If This ID Exists, If Yes Then Get Product
//Details, If No Then Exit Script and Give Message Why
$sql = mysql_query("SELECT * FROM products WHERE id='$id' LIMIT 1");
$productCount = mysql_num_rows($sql);
if ($productCount > 0) {
//Get All The Product Details
while ($row = mysql_fetch_array($sql)) {
$product_name = $row["product_name"];
$price = $row["price"];
$details = $row["details"];
$category = $row["category"];
$subcategory = $row["subcategory"];
$date_added = strftime("%b %d, %Y",strtotime($row["date_added"]));
}
} else {
echo "That Item Does Not Exist";
exit();
}
} else {
echo "Data To Render This Page Is Missing";
exit();
}
mysql_close();