-1

I had cart data in session like product_id, product_name, product_price..... so there is multiple data in session with array it's not fixed..sometime single data and sometime morethan one..... but when customer check out.... I need to check each product with customers entered pincode …..and products have multiple or single pincode in table....so we can get them by session product_id ..... then want to check if those pin match with client/user pincode then store in new session and those products which are not match yet....also move in another new session..... or just want to display product like allowed or not allowed product for this pin

is there any way to make it simple ? i think it's work with foreach inside condtions and all..but still confused.....sorry for bad english !

i had just wrote little code but confused what to next ?

if (!empty($_SESSION["shopping_cart"])){
    foreach ($_SESSION["shopping_cart"] as $keys => $value){
        $pro_session_id = $_SESSION["shopping_cart"][$keys]['product_id'];
        $select_price_data = mysql_query("select * from product_pincode where product_ID = '$pro_session_id'");

    }
}
Özgür Can Karagöz
  • 1,039
  • 1
  • 13
  • 32
Ha Moj Ha
  • 1
  • 2
  • Does this answer your question? [Why shouldn't I use mysql\_\* functions in PHP?](https://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php) – Dharman May 13 '20 at 16:26
  • i will deal with it bro....not that problem....main problem is to solve that issue ! @Dharman – Ha Moj Ha May 13 '20 at 16:31

1 Answers1

0
if (!empty($_SESSION["shopping_cart"])) {
    foreach ($_SESSION["shopping_cart"] as $keys => $value) {
        $pro_session_id = $_SESSION["shopping_cart"][$keys]['product_id'];
        // echo $pro_session_id;
        // echo "<br>";
        // $select_pin_data = mysql_query("select * from product_pincode where product_ID = '$pro_session_id'");
        $select_pin_query = "SELECT * FROM product_pincode WHERE product_ID = '$pro_session_id'";
        $selected = mysql_query($select_pin_query, $con) or die(mysql_error($con));
        $pin_val = array();
        while ($get_pin_data = mysql_fetch_assoc($selected)) {
            $pin_val[] = $get_pin_data;
        }
        foreach ($pin_val as $get_pin_data) {
            if ($get_pin_data['pincode_number'] == $_SESSION["order_placement_details"][0]['user_pincode']) {
                echo "Complete " . $get_pin_data['pincode_number'];
                echo "<br>";
            } else {
                echo "unallowed" . $get_pin_data['pincode_number'];
                echo "<br>";
            }
        }
    }
Özgür Can Karagöz
  • 1,039
  • 1
  • 13
  • 32
Ha Moj Ha
  • 1
  • 2