function total_price (){

    $total = 0;

    global $db;

    $ip = getIp();

      $sel_price = "select * from cart where ip_add='$ip'";
        $run_price = mysqli_query($db,$sel_price);
        while ($p_price= mysqli_fetch_array($run_price)){

            $product_id = $p_price['p_id'];

            $product_price = "select * from product where product_id='$product_id'";

            $run_pro_price = mysqli_query($db,$product_price);

            while ($pp_price= mysqli_fetch_array($run_pr0-_price)){

                $product_price = array($pp_price ['product_price']);

                $values = array_sum($product_price);
                $total +=$values;

                echo $total;
            }

            }
        }

The first step is learning PDO and making an attempt at converting it. Here is a good PDO tutorial to get you going. Click Here

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.