Total registered in Database with Script

0

My php page uses the following files "1-config.php = connects to the database" "2-total.php = connects to the Form and shows the total of the record on the page"

In the Html of my main page I use <?php require_once("total.php"); ?> , now comes the problem, I have a script at the bottom of the page that controls one of the functions of my page

<script type="text/javascript">
function verifica() {
    for (var a = 0; a < 39; a++) {
        var b = "s" + (a + 1),
            c = document.getElementById(b);
        if (c.innerHTML = segsToTime(c.getAttribute("inicial")), verificaCookie(b)) {
            var d = new Date,
                e = d.getTime() - getCookie(b),
                f = c.getAttribute("inicial") - parseInt(e / 1e3);
            c.innerHTML = segsToTime(f), f < 0 && (c.innerHTML = segsToTime(c.getAttribute("inicial")), invalidarCookie(b))
        }
    }
    setTimeout(function() {
        verifica()
    }, 1e3)
}

function dispara(a) {
    var b = document.getElementById(a),
        c = new Date,
        d = c.getTime();
    c.setTime(c.getTime() + 2e3 * b.getAttribute("inicial")), document.cookie = a + "=" + d + "; path=/"
}

function lerCookie(a) {
    var b = document.cookie.split("=");
    return b[1]
}

function verificaCookie(a) {
    return document.cookie.indexOf(a) != -1
}

function getCookie(a) {
    var b = document.cookie,
        c = a + "=",
        d = b.indexOf("; " + c);
    if (d == -1) {
        if (d = b.indexOf(c), 0 != d) return null
    } else d += 2;
    var e = b.indexOf(";", d);
    return e == -1 && (e = b.length), unescape(b.substring(d + c.length, e))
}

function invalidarCookie(a) {
    document.cookie = a + "=0; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/"
}

function segsToTime(a) {
    return h = parseInt(a / 3600), h < 10 && (h = "0" + h), m = parseInt(a / 60 % 60), m < 10 && (m = "0" + m), s = parseInt(a % 60), s < 10 && (s = "0" + s), h + ":" + m + ":" + s
}
verifica();
</script>

The problem is, how can I put the total register of the bd so that it stays automatic like the rest of the page? without having to migrate the script to php type "echo (" ... rest of the code ")" how can I do something in the html itself inside the script?

EX: function verifica(){for(var a=0;a<"total";a++)...resto do código

or

EX: function verifica(){for(var a=0;a<"<?php require_once("total.php");?>";a++)...resto do código (already tried this)

Thank you.

    
asked by anonymous 27.12.2016 / 18:59

1 answer

1

I think you already have the total given by $ x then:

    
27.12.2016 / 19:20