Jump to content


Photo

easy question array


  • Please log in to reply
No replies to this topic

#1 drunknbass

drunknbass
  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 13 April 2006 - 02:17 AM

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.

$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);

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





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users