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
https://forums.phpfreaks.com/topic/7268-easy-question-array/
Share on other sites

Archived

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

×
×
  • 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.