$manufacturer_name
$pro_title
$product_price $product_psp_price
/// IP address code starts /////
function getRealUserIp(){
switch(true){
case (!empty($_SERVER['HTTP_X_REAL_IP'])) : return $_SERVER['HTTP_X_REAL_IP'];
case (!empty($_SERVER['HTTP_CLIENT_IP'])) : return $_SERVER['HTTP_CLIENT_IP'];
case (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) : return $_SERVER['HTTP_X_FORWARDED_FOR'];
default : return $_SERVER['REMOTE_ADDR'];
}
}
/// IP address code Ends /////
// items function Starts ///
function items(){
global $db;
$ip_add = getRealUserIp();
$get_items = "select * from cart where ip_add='$ip_add'";
$run_items = mysqli_query($db,$get_items);
$count_items = mysqli_num_rows($run_items);
echo $count_items;
}
// items function Ends ///
// total_price function Starts //
function total_price(){
global $db;
$ip_add = getRealUserIp();
$total = 0;
$select_cart = "select * from cart where ip_add='$ip_add'";
$run_cart = mysqli_query($db,$select_cart);
while($record=mysqli_fetch_array($run_cart)){
$pro_id = $record['p_id'];
$pro_qty = $record['qty'];
$sub_total = $record['p_price']*$pro_qty;
$total += $sub_total;
}
echo "$" . $total;
}
// total_price function Ends //
// getPro function Starts //
function getPro(){
global $db;
$get_products = "select * from products order by 1 DESC LIMIT 0,8";
$run_products = mysqli_query($db,$get_products);
while($row_products=mysqli_fetch_array($run_products)){
$pro_id = $row_products['product_id'];
$pro_title = $row_products['product_title'];
$pro_price = $row_products['product_price'];
$pro_img1 = $row_products['product_img1'];
$pro_label = $row_products['product_label'];
$manufacturer_id = $row_products['manufacturer_id'];
$get_manufacturer = "select * from manufacturers where manufacturer_id='$manufacturer_id'";
$run_manufacturer = mysqli_query($db,$get_manufacturer);
$row_manufacturer = mysqli_fetch_array($run_manufacturer);
$manufacturer_name = $row_manufacturer['manufacturer_title'];
$pro_psp_price = $row_products['product_psp_price'];
$pro_url = $row_products['product_url'];
if($pro_label == "Sale" or $pro_label == "Gift"){
$product_price = " $$pro_price ";
$product_psp_price = "| $$pro_psp_price";
}
else{
$product_psp_price = "";
$product_price = "$$pro_price";
}
if($pro_label == ""){
}
else{
$product_label = "