Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

91
Vistas
Array is outputting new data below instead of overwriting

I have a PHP file with the following script in it that I think is where the issue lies. The PHP file is to check for event information and post the event and times on a display board. It does this check every 5 minutes

What is happening is that it is appending the new information to the previous information instead of overwriting/refreshing it.

So the output every 5 minutes would look similar to the following (without the *5 minutes later):

12:00-1:00pm Lunch 12:00-1:00pm Lunch *5 minutes later 12:00-1:00pm Lunch *5 minutes later ...

The checks every 5 minutes needs to happen in case events get updated or changed. As you can see from the above, it appends instead of overwrites.

Here is the section of code I believe where the issue lies in how the array is handled.

    function init_event(){
$.ajax({

url:"php/event-query.php",

data:{activeId:SETTING_DATA.facility},success:function(e){

var t=JSON.parse(e),n=Date.now()/1e3|0;

if(!SETTING_DATA.show_passed_events)
for(var i in t)
t.hasOwnProperty(i)&&n>t[i].time_to&&delete t[i];

if($.isEmptyObject(t))$("#event-text").css("display","block"),$("#event-table").css("display","none");

else{
$("#event-text").css("display","none"),$("#event-table").css("display","table");

var o,a=Math.floor(window.innerHeight/window.innerWidth*9),l=document.getElementById("event-table-body"),c="#000000",r=1/((r=Object.keys(t).length)<=a?r:a),d=0;

for(o in t)

if(t.hasOwnProperty(o)){
var s=document.createElement("tr"), m=t[o].time_from,u=t[o].time_to,_=document.createElement("td");

_.appendChild(document.createTextNode(format_time(m,u))),s.appendChild(_);

_=document.createElement("td");

if(_.appendChild(document.createTextNode(t[o].name)),s.appendChild(_),s.style.color=c,s.style.color=m<n&&n<u&&SETTING_DATA.highlight_current?"#4da6ff":c,l.appendChild(s),c=shadeColour(c,r*++d/1.5-.1),d==a)break}}}}),setTimeout(function(){

init_event()
},3e5

)

}
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda