Jump to content

delete product


feof84

Recommended Posts

Hi,

 

I wrote a function to launch when I have to delete a product.

It 'correct?

 

 

 

function delete_product($id_product)

{

$db = mysql_connect(host, user, password) or die("Connessione non riuscita: " . mysql_error());

mysql_select_db(database, $db) or die ("Impossibile connettersi al database database<br>");

 

/* elimino il prodotto dalla tab ps_product */

 

$q = "DELETE FROM `ps_product` WHERE `ps_product`.`id_product`=$id_product";

$result=mysql_query($q);

if (!$result) {

die('Invalid query: ' . mysql_error());

}

 

/* elimino il prodotto dalla tab ps_category_product */

 

$q = "DELETE FROM `ps_category_product` WHERE `ps_category_product`.`id_product` =$id_product";

$result=mysql_query($q);

if (!$result) {

die('Invalid query: ' . mysql_error());

}

 

/* elimino il prodotto dalla tab */

$q = "DELETE FROM `ps_product_lang` WHERE `ps_product_lang`.`id_product` =$id_product";

$result=mysql_query($q);

if (!$result) {

die('Invalid query: ' . mysql_error());

}

 

/* elimino le immagini associate al prodotto */

$q = "DELETE FROM `ps_image` WHERE `ps_image`.`id_product` =$id_product";

$result=mysql_query($q);

if (!$result) {

die('Invalid query: ' . mysql_error());

}

 

mysql_close($db);

return TRUE;

}

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...