我想在文本框中将总值和计数器值传递给另一个php页面,并保存到数据库中

i want to pass total and counter value to another php page in a text box and save to database?

本文关键字:页面 php 另一个 保存 数据库 计数器 文本 值传      更新时间:2023-09-26

我想将总值和计数器值传递到文本框中的另一个PHP页面,并保存到数据库中。

{
    var price =10;
    //price
    $(document).ready(function() {
        var $cart = $('#selected-seats'),  //Sitting Area
            $counter = $('#counter'),  //Votes
            $total = $('#total');  //Total money
        var sc = $('#seat-map').seatCharts({
                map: [  //Seating chart
                        '_______a',
                        '________',
                        'aa____aa',
                        'aa____aa',
                        'aa____aa',
                        'aa____aa',
                        'aa____aa',
                        'aa____aa',
                        'aa____aa',
                        'aa____aa',
                        'aa____aa'
                ],
                naming: {
                    top: false,
                    getLabel: function (character, row, column) {
                        return column;
                    }
                },
                legend: { //Definition legend
                    node: $('#legend'),
                    items: [
                        [ 'a', 'available','Available' ],               
                        [ 'a', 'unavailable', 'Booked']
                    ]                   
                },
                click: function () { //Click event
                    if (this.status() == 'available') { //optional seat
                        $('<li>R'+(this.settings.row+1)+' S'+this.settings.label+'</li>')
                            .attr('id', 'cart-item-'+this.settings.id)
                            .data('seatId', this.settings.id)
                            .appendTo($cart);
                        $counter.text(sc.find('selected').length+1);
                        $total.text(recalculateTotal(sc)+price);
                        return 'selected';
                    } else if (this.status() == 'selected') { //Checked
                        //Update Number
                        $counter.text(sc.find('selected').length-1);
                        //update totalnum
                        $total.text(recalculateTotal(sc)-price);
                        //Delete reservation
                        $('#cart-item-'+this.settings.id).remove();
                        //optional
                        return 'available';
                    } else if (this.status() == 'unavailable') { //sold
                        return 'unavailable';
                    } else {
                        return this.style();
                    }
                }
        });
        //sold seat
        sc.get(['1_8','4_4','4_5','6_6','6_7','8_5','8_6','8_7','8_8','10_1', '10_2']).status('unavailable');   
    });
    //sum total money
    function recalculateTotal(sc) {
        var total = 0;
        sc.find('selected').each(function () {
            total += price;
        }); 
        return total;  //here returning total amount
    }
}
// You can use this "Javascript" code to navigate to the next page
window.location = "savetodbpage.php?total=" + $total + "&counter=" + $counter
// PHP To receive the params
<?php
$total = @$_GET[ "total" ];
$counter = @$_GET[ "counter" ];
// Below you can either update / insert these values into your database. You have not mentioned much in your question so this is how far I can go helping you. Look up on SQL Insert / Update queries depending on what you actually want to do...
?>