示例#1
0
 * setting the database value for stock column
 */
if ($stock > 5) {
    $status = 1;
} else {
    $status = 0;
}
//varriable which will contain the category in string format
$category_string = "";
if (!empty($GLOBALS['_POST']['category']) && $GLOBALS['_POST'] > 0) {
    $category = $GLOBALS['_POST']['category'];
    //convert array to string seperated by commas
    foreach ($category as $cate) {
        $category_string = $category_string . "," . $cate;
    }
    /*
    - remove the first word from the $category_string sa it
    - it contains a comma
    */
    $category_string = substr($category_string, 1);
}
//discount is set or not
if (!empty($discount)) {
    //insert values in product table
    $result = $manageData->insertCoupon($coupon_id, $category_string, $coupon_name, $description, $references, $coupon_code, $old_price, $price_guest, $price_members, $tax, $discount, $stock, $date, $expiration_date, $maxpick, $status, $photo_name, $photo_name1, $photo_name2, $photo_name3, $photo_name4);
    if ($result == 1) {
        header("Location: ../../addCoupon.php?msg=1111");
    }
} else {
    header("Location: ../../addCoupon.php?msg=9999");
}