Jump to content

easy question array


drunknbass

Recommended Posts

ok i have a question that shoudl be easy. when i delete a product from the cart i want ti to also delete all the attribute entires related to that product out of thier tables. there is a table store_classes and store_class_options

i can get it to delete all records out of classes when the product is deleted, but i think i need an array or something to get rid of all the options to those classes, it only deltes the entries in the table for the first class.
example

color:Black
White

Size:small
Large

it will delete the classes for size and color, but it will only delte the class_options for color (black, white)
the small and large stay in the table
maybe i need a loop or something..
heres my code.

[code]
$sql_class_class = "select * from ".$prefix."store_classes where productid = $product";
             $result1 = mysql_query ($sql_class_class);
             $row1 = mysql_fetch_array($result1);
             $classid = $row1["classid"];
         $sql_class_options = "select * from ".$prefix."store_class_options where classid = $classid";
            $result1 = mysql_query ($sql_class_options);
            $row1 = mysql_fetch_array($result1);
            $classid = $row1["classid"];
       $result = "delete FROM ".$prefix."store_inventory WHERE product='$product'";
       $row = mysql_query($result);
       $result = "delete FROM ".$prefix."store_classes WHERE productid='$product'";
       $row = mysql_query($result);
       $result = "delete FROM ".$prefix."store_class_options WHERE classid='$classid'";
       $row = mysql_query($result);
[/code]

i know why it only deletes the first class options, because it doesnt array the classid for each class, it only returns the value for the first entry
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.