Exemple #1
0
<?php

//Add Product
if (isset($_POST['add_product'])) {
    pb_add_product($_SESSION['user_id']);
}
// Account settings
if (isset($_POST['account_submit'])) {
    pb_update_account($_SESSION['user_id']);
}
// Commenting
if (isset($_POST['add_comment'])) {
    pb_add_comment($_SESSION['user_id']);
}
// My Service
if (isset($_POST['add_servise'])) {
    pb_add_servise($_SESSION['user_id']);
}
// My Service Reveiw
if (isset($_POST['add_reveiw'])) {
    pb_add_reveiw($_SESSION['user_id']);
}
function pb_add_reveiw($user_id)
{
    pb_add_comment($user_id);
    $svr_id = $_POST['post_id'];
    $ratings = $_POST['ratings'];
    if ($ratings > '0') {
        if ($ratings > '0') {
            $r = '3';
        }
        if ($ratings > '25') {
            $r = '3.5';
        }
        if ($ratings > '50') {
            $r = '4';
        }
        if ($ratings > '75') {
            $r = '4.5';
        }
        if ($ratings > '90') {
            $r = '5';
        }
    } else {
        if ($ratings < '0') {
            $r = '3';
        }
        if ($ratings < '-25') {
            $r = '3.5';
        }
        if ($ratings < '-50') {
            $r = '2';
        }
        if ($ratings < '-75') {
            $r = '1.5';
        }
        if ($ratings < '-90') {
            $r = '1';
        }
    }
    $indb = pb_table_data('pb_services', 'ratings', "service_id='{$svr_id}'");
    $tot = (double) $r + (double) $indb;
    $adv = $tot / 2;
    return pb_db("UPDATE pb_services SET ratings='{$adv}' WHERE service_id='{$svr_id}'");
}