Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

SQL - updating two tables


maxiim

Recommended Posts

Posted

I have installed Product inventory editor 1.0 and added a price column so that I can edit products price, weight and stock in one place. Now I would like to add special prices too but I don`t know how to update "s.specials_new_products_price" column. Any suggestions how to add updating of "specials" table to the last if statement?

 

 

if($_REQUEST['prod_search']!="")
{
$product_query = tep_db_query("select pd.products_name, p.products_id, p.products_price, s.specials_new_products_price, p.products_quantity, 
p.products_model, p.products_weight from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_SPECIALS . " s where p.products_id = pd.products_id 
and pd.language_id = '" . (int)$languages_id . "' and p.products_id = s.products_id and pd.products_name like '".$_REQUEST['prod_search']."%'");
}
else
{
$product_query = tep_db_query("select pd.products_name, p.products_id, p.products_price, s.specials_new_products_price, p.products_quantity, 
p.products_model, p.products_weight from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_SPECIALS . " s where p.products_id = pd.products_id 
and pd.language_id = '" . (int)$languages_id . "' and p.products_id = s.products_id order by pd.products_name");
}
 if($_REQUEST['update']=="update")
 {
  while($product1 = tep_db_fetch_array($product_query))
		{

		$str=tep_db_query("update products set products_price='".$_REQUEST['price_'.$product1['products_id']]."', 
products_weight='".$_REQUEST['weight_'.$product1['products_id']]."', products_quantity='".$_REQUEST['qty_'.$product1['products_id']]."' 
where products_id='".$product1[products_id]."'");

		}
		header("location:product_list.php?Update=Success&prod_search=".$_REQUEST['prod_search']);

 }

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...