Thứ Hai, 3 tháng 8, 2026

Day - Date - Month - Year PHP

 

$thoigian  = $value["thoigian"]; ("2026-07-31 14:41:39")

$timestamp = strtotime($thoigian);

$days = array(

    'Sunday'    => 'Chủ nhật',

    'Monday'    => 'Thứ Hai',

    'Tuesday'   => 'Thứ Ba',

    'Wednesday' => 'Thứ Tư',

    'Thursday'  => 'Thứ Năm',

    'Friday'    => 'Thứ Sáu',

    'Saturday'  => 'Thứ Bảy'

);

$day = $days[date('l', $timestamp)];

<div class="pdnews-times">

    <span><img src="/themes/'.$ThemeSel.'/images/icon-blog2.png"> '.$day.',</span>

    <span class="news_home_content_short_time">

        '.date('d/m/Y', $timestamp).'

    </span>

</div>

Thứ Ba, 28 tháng 7, 2026

Chọn vị trí để IN (print) ra nội dung của div

 ** HTML

<div id="printArea">

    <div class="no-print">Nội dung left</div>


    <div class="content-right">Nội dung phải</div>

    <!--Nội dung phải được in ra-->

</div>


** CSS

<style type="text/css">

    @media print{

        .certificate-container{

            margin:0 !important;

            padding:8mm !important;

            height:auto !important;

            min-height:auto !important;

        }

        .certificate-inner-border{

            padding:6mm !important;

        }

        p,h1,h2,h3,h4,h5,h6{

            margin-top:2px !important;

            margin-bottom:2px !important;

        }

        .no-print{

            display:none!important;

        }

        body *{

            visibility:hidden;

        }

        #printArea,

        #printArea *{

            visibility:visible;

        }


        #printArea{

            position:absolute;

            left:0;

            top:0;

            width:100%;

        }

    }

</style>


** JS

<script type="text/javascript">

    function printDiv(){

        window.print();

    }

</script>


Thứ Hai, 20 tháng 7, 2026

Nhập số tự chuyển thành "period / dot" và "comma"

** HTML
<input type='text' name='currency' id='currency' class='form-control'>

Nhập 25500 -> thành 25.500

** PHP

Code php lấy lại giá trị: 25500

$currency = str_replace('.', '', $_POST['currency']);

** JS

<script type="text/javascript">

    $("#currency").on("input", function () {

        // Chỉ giữ lại số

        let value = $(this).val().replace(/\D/g, "");

        // Format 25.500

        if (value !== "") {

            value = Number(value).toLocaleString("vi-VN");

        }

        $(this).val(value);

    });

</script> 

Thứ Ba, 14 tháng 7, 2026

explode - implode - uploads Images code php

 ##┌────────────────────────────────────────────────┐     

  ## Implode

##└────────────────────────────────────────────────┘

function ConvertImplode($post){    

    if(empty($post) || !is_array($post)){

        return '';

    }

    $post = array_map('trim', $post);

    $post = array_filter($post);

    return implode('**', $post);

}

$maymoc1 = ConvertImplode($_POST['maymoc1']);

$maymoc2 = ConvertImplode($_POST['maymoc2']);

$maymoc3 = ConvertImplode($_POST['maymoc3']);

$maymoc4 = ConvertImplode($_POST['maymoc4']);


##┌────────────────────────────────────────────────┐     

  ## upload-image

##└────────────────────────────────────────────────┘

function uploadVerifiedImage($file, $path){

    if (!isset($file['tmp_name']) || $file['error'] != 0) {

        return '';

    }

    $ext = strtolower(pathinfo($file['name'], PATHINFO_EXTENSION));

    $allow = array('jpg','jpeg','png','gif','webp');

    if (!in_array($ext, $allow)) {

        return '';

    }

    $filename = time().'_'.mt_rand(1000,9999).'.'.$ext;

    if (move_uploaded_file($file['tmp_name'], $path.$filename)) {

        return $filename;

    }

    return '';

}

$path = "uploads/verified/";

if (!is_dir($path)) {
        mkdir($path, 0777, true);
}

$gate_image = uploadVerifiedImage($_FILES['gate_image'], $path);

$production_image = uploadVerifiedImage($_FILES['production_image'], $path);

$machinery_image = uploadVerifiedImage($_FILES['machinery_image'], $path);

$certificate_file = uploadVerifiedImage($_FILES['certificate_file'], $path);

$video_file = uploadVerifiedImage($_FILES['video_file'], $path);  


if($gate_image != ''){

     $input_data['gate_image'] = $gate_image;

}

if($production_image != ''){

     $input_data['production_image'] = $production_image;

}

if($machinery_image != ''){

        $input_data['machinery_image'] = $machinery_image;

}

if($certificate_file != ''){

     $input_data['certificate_file'] = $certificate_file;

}

if($video_file != ''){

     $input_data['video_file'] = $video_file;

}    

##┌────────────────────────────────────────────────┐     

  ## Note: RESULT

##└────────────────────────────────────────────────┘

$input_data = array(

    'bangke1'  => $bangke1,

    'bangke2'  => $bangke2,

);

$xsql = "SELECT id FROM api_Vfactory WHERE shopid=".$shopid;

$rs   = $db->sql_query($xsql);

if($db->sql_numrows($rs)){

    // UPDATE

    $sql = "UPDATE api_Vfactory SET "

        .$db->sql_build_array('UPDATE', $input_data)

        ." WHERE shopid=".$shopid;

}else{

    // INSERT

    $input_data['shopid'] = $shopid;

    $input_data['created_at'] = time();

    $sql = "INSERT INTO api_Vfactory "

        .$db->sql_build_array('INSERT', $input_data);

}


##┌────────────────────────────────────────────────┐     

  ## Note: explode

##└────────────────────────────────────────────────┘ 

function parseData($value){

    return !empty($value) ? explode('**', $value) : array();

}

$data = data__Vfactory($shopid);

extract($data[0]);

$bangke1 = parseData($bangke1);

$bangke2 = parseData($bangke2);

foreach ($bangke1 as $key => $value) {

    <tr>

        <td>'.$value.'</td>

        <td>'.$bangke2[$key].'</td>

    </tr>

}

Thứ Tư, 8 tháng 7, 2026

Hiệu ứng Popup - Detail Product

 



## HTML

<!DOCTYPE html>
<html lang="vi">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Slide Popup Lightbox</title>
    <link rel="stylesheet" href="style.css">
</head>
<body>

<!-- Danh sách các hình ảnh hiển thị trên trang -->
<div class="image-gallery">
    <div class="gallery-item">
        <img src="1.jpg" alt="máy giặt bong bóng" class="popup-trigger"
             data-title-vi="máy giặt bong bóng" 
             data-date="May 19,2021" 
             data-title-en="Bubble Washing Machine" 
             data-desc="The bubbling cleaning machine is designed for materials with high shape requirements. It is...">
        <p>máy giặt bong bóng</p>
    </div>
    <div class="gallery-item">
        <img src="2.jpg" alt="máy chiết rót nước sốt" class="popup-trigger"
             data-title-vi="máy chiết rót nước sốt" 
             data-date="June 10,2022" 
             data-title-en="Sauce Filling Machine" 
             data-desc="Description for sauce filling machine goes here...">
        <p>máy chiết rót nước sốt</p>
    </div>
    <!-- Thêm các hình ảnh khác tại đây -->
</div>

<!-- Cấu trúc MODAL POPUP (Giống như trong ảnh z7975352149535_20ea4773eb8dace4aa835ec268dc0eab.jpg) -->
<div id="lightboxModal" class="modal">
    <!-- Nút đóng góc trên bên phải bên ngoài hoặc sát mép -->
    <span class="close-btn">&times;</span>
    
    <div class="modal-content">
        <!-- Phần Header của Popup -->
        <div class="modal-header">
            <h3 id="modalTitleVi">máy giặt bong bóng</h3>
            <span id="modalDate">May 19,2021</span>
        </div>

        <!-- Phần Thân chứa Ảnh và Nút chuyển đổi -->
        <div class="modal-body">
            <button class="nav-btn prev-btn">&#10094;</button>
            <div class="image-container">
                <img id="modalImage" src="" alt="Popup Image">
            </div>
            <button class="nav-btn next-btn">&#10095;</button>
        </div>

        <!-- Phần Footer chứa Mô tả -->
        <div class="modal-footer">
            <h4 id="modalTitleEn">Bubble Washing Machine</h4>
            <div class="desc-scroll">
                <p id="modalDesc">The bubbling cleaning machine is designed for materials with high shape requirements. It is...</p>
            </div>
        </div>
    </div>
</div>

<script src="script.js"></script>

<style type="text/css">
    
    /* Gallery ngoài trang */
body {
    font-family: Arial, sans-serif;
    background-color: #f4f4f4;
    margin: 0;
    padding: 20px;
}
.image-gallery {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}
.gallery-item {
    background: #fff;
    padding: 10px;
    border: 1px solid #ddd;
    text-align: center;
    cursor: pointer;
    width: 200px;
}
.gallery-item img {
    width: 100%;
    height: auto;
}

/* MODAL BACKGROUND */
.modal {
    display: none; /* Ẩn mặc định */
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.5); /* Nền tối mờ phía sau */
    justify-content: center;
    align-items: center;
}

/* NÚT ĐÓNG (X) */
.close-btn {
    position: absolute;
    top: 20px;
    right: 30px;
    color: #fff;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    background: rgba(0,0,0,0.3);
    width: 45px;
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}
.close-btn:hover {
    background: rgba(0,0,0,0.6);
}

/* KHUNG POPUP CHÍNH */
.modal-content {
    background-color: #fff;
    width: 90%;
    max-width: 800px;
    border-radius: 4px;
    display: flex;
    flex-direction: column;
    position: relative;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

/* HEADER POPUP */
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 25px;
    border-bottom: 1px solid #eee;
}
.modal-header h3 {
    margin: 0;
    font-size: 16px;
    color: #333;
    font-weight: bold;
}
.modal-header span {
    font-size: 13px;
    color: #888;
}

/* THÂN POPUP CHỨA ẢNH VÀ DI CHUYỂN */
.modal-body {
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    padding: 10px 0;
    background: #fff;
}
.image-container {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 400px; /* Chiều cao cố định cho vùng chứa ảnh */
}
.image-container img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* NÚT NEXT / PREV TRÁI PHẢI */
.nav-btn {
    background: rgba(0, 0, 0, 0.4);
    color: white;
    border: none;
    padding: 15px 12px;
    cursor: pointer;
    font-size: 20px;
    position: absolute;
    z-index: 10;
    transition: 0.2s;
}
.nav-btn:hover {
    background: rgba(0, 0, 0, 0.7);
}
.prev-btn { left: 0; border-radius: 0 4px 4px 0; }
.next-btn { right: 0; border-radius: 4px 0 0 4px; }

/* FOOTER POPUP CHỨA MÔ TẢ */
.modal-footer {
    padding: 20px 25px;
    border-top: 1px solid #eee;
    background: #fff;
}
.modal-footer h4 {
    margin: 0 0 10px 0;
    font-size: 16px;
    color: #444;
}


/* Tạo thanh cuộn cho nội dung dài giống hình ảnh mẫu */
.desc-scroll {
    max-height: 80px;
    overflow-y: auto;
    padding-right: 10px;
}
.desc-scroll p {
    margin: 0;
    font-size: 13px;
    color: #666;
    line-height: 1.5;
}
/* Tùy biến thanh cuộn đẹp hơn */
.desc-scroll::-webkit-scrollbar {
    width: 6px;
}
.desc-scroll::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}
</style>

<script type="text/javascript">
    document.addEventListener("DOMContentLoaded", function () {
    const modal = document.getElementById("lightboxModal");
    const triggers = document.querySelectorAll(".popup-trigger");
    const closeBtn = document.querySelector(".close-btn");
    
    const modalImg = document.getElementById("modalImage");
    const modalTitleVi = document.getElementById("modalTitleVi");
    const modalDate = document.getElementById("modalDate");
    const modalTitleEn = document.getElementById("modalTitleEn");
    const modalDesc = document.getElementById("modalDesc");
    
    const prevBtn = document.querySelector(".prev-btn");
    const nextBtn = document.querySelector(".next-btn");

    let currentIndex = 0;

    // Hàm cập nhật nội dung cho Modal dựa trên Index của ảnh
    function updateModal(index) {
        const targetImg = triggers[index];
        
        modalImg.src = targetImg.src;
        modalTitleVi.textContent = targetImg.getAttribute("data-title-vi");
        modalDate.textContent = targetImg.getAttribute("data-date");
        modalTitleEn.textContent = targetImg.getAttribute("data-title-en");
        modalDesc.textContent = targetImg.getAttribute("data-desc");
        
        currentIndex = index;
    }

    // Lắng nghe sự kiện click vào từng bức ảnh
    triggers.forEach((trigger, index) => {
        trigger.addEventListener("click", function () {
            modal.style.display = "flex";
            updateModal(index);
        });
    });

    // Nút quay lại (Trái)
    prevBtn.addEventListener("click", function (e) {
        e.stopPropagation(); // Tránh lỗi tắt modal ngoài ý muốn
        let newIndex = currentIndex - 1;
        if (newIndex < 0) {
            newIndex = triggers.length - 1; // Quay về ảnh cuối cùng nếu vượt quá đầu danh sách
        }
        updateModal(newIndex);
    });

    // Nút kế tiếp (Phải)
    nextBtn.addEventListener("click", function (e) {
        e.stopPropagation();
        let newIndex = currentIndex + 1;
        if (newIndex >= triggers.length) {
            newIndex = 0; // Quay về ảnh đầu tiên nếu vượt quá cuối danh sách
        }
        updateModal(newIndex);
    });

    // Đóng modal khi bấm nút X
    closeBtn.addEventListener("click", function () {
        modal.style.display = "none";
    });

    // Đóng modal khi click ra vùng ngoài khung trắng
    modal.addEventListener("click", function (e) {
        if (e.target === modal) {
            modal.style.display = "none";
        }
    });
    
    // Hỗ trợ bấm nút điều hướng bằng bàn phím (Trái/Phải/Esc)
    document.addEventListener("keydown", function(e) {
        if (modal.style.display === "flex") {
            if (e.key === "ArrowLeft") {
                prevBtn.click();
            } else if (e.key === "ArrowRight") {
                nextBtn.click();
            } else if (e.key === "Escape") {
                modal.style.display = "none";
            }
        }
    });
});
</script>
</body>
</html>

## Demo

Link: https://vietb2b.com/nha-cung-cap-6-profile


Thứ Hai, 6 tháng 7, 2026

Hover Button css đẹp

 

## HTML

<div class="box-send-contact">

    <button class="button dark">Gửi thông tin</button>

</div>


## CSS

.button.dark {

    color: #fff;

    border-color: #0d2445;

}

.box-send-contact button {

    display: block;

    margin: 2rem auto 3rem auto;

}

.button:before {

    position: absolute;

    content: '';

    display: block;

    left: -2px;

    top: 0;

    right: -2px;

    bottom: 0;

    transform: scale(1, 1);

    transform-origin: left center;

    z-index: -1;

    background-color: #ffffff;

    transition: transform 0.45s cubic-bezier(0.785, 0.135, 0.15, 0.86);

}

.button.dark:before {

    background-color: #0d2445;

}

.button {

    font-weight: 600;

    position: relative;

    display: inline-block;

    padding: 1rem 2.8rem;

    line-height: normal;

    border: 1px solid #ffffff;

    border-radius: 50px;

    text-transform: uppercase;

    font-size: 1.2rem;

    text-align: center;

    letter-spacing: 1px;

    background-color: transparent;

    transition: color 0.45s cubic-bezier(0.785, 0.135, 0.15, 0.86), border 0.45s cubic-bezier(0.785, 0.135, 0.15, 0.86);

    z-index: 1;

    color: #0d2445;

    overflow: hidden;

}

.button:hover:before {

    transform-origin: right center;

    transform: scale(0, 1);

}

button:focus:not(:focus-visible) {

    outline: 0;

}

button.dark:hover {

    color: #0d2445;

}