Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

207
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!