Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

223
Visualizações
Merge SQL Data in Row, HTML Table using Jquery

I am trying to merge data in row on the basis of date, but I got this

enter image description here

I need the result like this

enter image description here

The columns are generating dynamically. This is logic I tried. Please guide me. Thank you.

var vHtml = '<table id="example_Day" class="table table-hover" cellspacing="0" width="100%">';
vHtml += '<thead>';
vHtml += '<tr id="rowDay">';
vHtml += '<th>Date</th>';
for (var i = 0; i < count; i++) {
    ProductArray.push(Returndata[i]["ShortCode"]);
    DateArray.push(Returndata[i]["DemandDate"]);
    MedIDArray.push(Returndata[i]["MedicineID"]);
}
ProductArray = ProductArray.filter(onlyUnique);
for (var i = 0; i < ProductArray.length; i++) {
    vHtml += '<th>' + ProductArray[i] + '</th>';
}
vHtml += '<th>Paid / Free</th>';
vHtml += '</tr>';
vHtml += '</thead>';
vHtml += '<tbody>';
DateArray = DateArray.filter(onlyUnique);
MedIDArray = MedIDArray.filter(onlyUnique);

for (var j = 0; j < count; j++) {
    vHtml += '<tr>';
    vHtml += '<td>' + Returndata[j]["DemandDate"] + '</td>';

    for (var i = 0; i < MedIDArray.length; i++) {
        if (MedIDArray[i] == Returndata[j]["MedicineID"]){
            vHtml += '<td>' + Returndata[j]["Amount"] + '</td>';
        }
        else
        {
            vHtml += '<td> - </td>';
        }
    }
    vHtml += '<td>' + Returndata[j]["FreeOrPaid"] + '</td>';
    vHtml += '</tr>';
}



vHtml += '</tbody>';
vHtml += '</table>';

$('#table_day').html(vHtml);

1:

2:

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda