splitting up values from database in html table

Viewed 70

I am putting items into my html table which are coming from my database. these items are being stored in there from each order placed on my website. so if someone orders two items, I basically want to show, this:

| NAME  | $    | QTY |
|:----  |:----:|   -:|
| item1 | 2.25 |   1 |
|:----  |:----:|   -:|
| item2 | 4.91 |   2 |

but right now, I am getting

| NAME  | $    | QTY |
|:----  |:----:|   -:|
| item1item2 | 2.25 |   1 |

here's my front end code. I don't think backend code is necessary for this, but correct me if im wrong!

 <table class="table table-bordered" id="dataTable" width="100%" cellspacing="0">
                <% if(data.length){ 
                    for(var i = 0;i < data.length;i++) { %>
              <h4>ORDER DETAILS FOR ORDER NUMBER <%= data[i].ORDERNUM %></h4>
              <% }
            }else{ %>
                <% } %>
              <thead>
                <tr>
                  <th>ORDER NUMBER</th>
                  <th>ITEM NAME</th>
                  <th>PRICE</th>
                  <th>QTY</th>
                  <th>EACH CASE</th>
                  <th>SIZE</th>
                </tr>
              </thead>
              <tbody>
                <% if(data.length){ 
                    for(var i = 0;i < data.length;i++) { %>
                <tr>
                  <td><%= data[i].ORDERNUM %></td>
                  <td><%= data[i].ITEMNAME %></td>
                  <td><%= data[i].ITEMPRICE %></td>
                  <td><%= data[i].QTY %></td>
                  <td><%= data[i].EACH_CASE %></td>

                  <script>
                      if ("<%= data[i].SIZE %>" == "undefined") {
                          document.write("<td>N/A</td>")
                      } else {
                          document.write("<td><%= data[i].SIZE %></td>")
                      }
                  </script>
              </tbody>
              <% }
            }else{ %>
                <% } %>
            </table>

not sure how to fix.. thanks for the help!

0 Answers
Related