I am having trouble with the way my data is being displayed. Any data that is entered into the first and second tables will not be displayed, but anything entered into the 3rd table will be displayed in not only the 3rd table, but the first and second as well. How can I change this so the data can be displayed in each table separately.
Here is an example of what it looks like:
Here is my HTML/PHP related code:
<p>
<div class="border1">
<div id="rebate_400p">
<strong>400P</strong><br>
</div>
<?php if(isset($_POST['rows'])): ?>
<table cellspacing="20">
<tr align="center" class="table_row">
<td>Tier</td>
<td>Purchase Minimum</td>
<td>Multiplier</td>
<td>UOM</td>
<td>Retro</td>
<td>Guaranteed</td>
<td>Paid</td>
</tr>
<?php
$count = 1;
foreach($_POST['rows'] as $row):
?>
<tr align="center">
<td><?php echo $count; ?></td>
<td><?php echo $row['purchase_minimum']; ?></td>
<td><?php echo $row['multiplier']; ?></td>
<td><?php echo $row['uom']; ?></td>
<td><?php echo $row['retro']; ?></td>
<td><?php echo $row['guaranteed']; ?></td>
<td><?php echo $row['paid']; ?></td>
</tr>
<?php
$count++;
endforeach;
?>
</table>
<?php endif; ?>
</div>
</p>
<!-- 400M -->
<p>
<div class="border1">
<div id="rebate_400m">
<strong>400M</strong><br>
</div>
<?php if(isset($_POST['rows'])): ?>
<table cellspacing="20">
<tr align="center" class="table_row">
<td>Tier</td>
<td>Purchase Minimum</td>
<td>Multiplier</td>
<td>UOM</td>
<td>Retro</td>
<td>Guaranteed</td>
<td>Paid</td>
</tr>
<?php
$count = 1;
foreach($_POST['rows'] as $row):
?>
<tr align="center">
<td><?php echo $count; ?></td>
<td><?php echo $row['purchase_minimum']; ?></td>
<td><?php echo $row['multiplier']; ?></td>
<td><?php echo $row['uom']; ?></td>
<td><?php echo $row['retro']; ?></td>
<td><?php echo $row['guaranteed']; ?></td>
<td><?php echo $row['paid']; ?></td>
</tr>
<?php
$count++;
endforeach;
?>
</table>
<?php endif; ?>
</div>
</p>
<!-- 400D -->
<p>
<div class="border1">
<div id="rebate_400d">
<strong>400D</strong><br>
</div>
<?php if(isset($_POST['rows'])): ?>
<table cellspacing="20">
<tr align="center" class="table_row">
<td>Tier</td>
<td>Purchase Minimum</td>
<td>Multiplier</td>
<td>UOM</td>
<td>Retro</td>
<td>Guaranteed</td>
<td>Paid</td>
</tr>
<?php
$count = 1;
foreach($_POST['rows'] as $row):
?>
<tr align="center">
<td><?php echo $count; ?></td>
<td><?php echo $row['purchase_minimum']; ?></td>
<td><?php echo $row['multiplier']; ?></td>
<td><?php echo $row['uom']; ?></td>
<td><?php echo $row['retro']; ?></td>
<td><?php echo $row['guaranteed']; ?></td>
<td><?php echo $row['paid']; ?></td>
</tr>
<?php
$count++;
endforeach;
?>
</table>
<?php endif; ?>
</div>
</p>
Here is some of my Javascript code:
// ----- Deletes row for 400p -----
function deleteRow(row)
{
var i=row.parentNode.parentNode;
i.parentNode.removeChild(i);
}
// ----- Adds row for 400p -----
function insRow()
{
var x=document.getElementById('tables');
var new_row = x.rows[1].cloneNode(true);
var len = x.rows.length;
new_row.cells[0].innerHTML = len;
var inp1 = new_row.cells[1].getElementsByTagName('input')[0];
inp1.id += len;
inp1.value = '';
var inp2 = new_row.cells[2].getElementsByTagName('input')[0];
inp2.id += len;
inp2.value = '';
var inputs = new_row.querySelectorAll('input[type=text]');
for(var i=0;i<inputs.length;i++)
{
inputs[i].value='';
inputs[i].name='rows[' + len + '][' + inputs[i].dataset.name + ']';
}
x.appendChild(new_row)
}
// ----- JS for 400M -----
// ----- Deletes row for 400m -----
function deleteRow1(row)
{
var i=row.parentNode.parentNode;
i.parentNode.removeChild(i);
}
// ----- Adds row for 400m -----
function insRow1()
{
var x=document.getElementById('tables1');
var new_row1 = x.rows[1].cloneNode(true);
var len = x.rows.length;
new_row1.cells[0].innerHTML = len;
var inp1 = new_row1.cells[1].getElementsByTagName('input')[0];
inp1.id += len;
inp1.value = '';
var inp2 = new_row1.cells[2].getElementsByTagName('input')[0];
inp2.id += len;
inp2.value = '';
var inputs = new_row1.querySelectorAll('input[type=text]');
for(var i=0;i<inputs.length;i++)
{
inputs[i].value='';
inputs[i].name='rows[' + len + '][' + inputs[i].dataset.name + ']';
}
x.appendChild(new_row1)
}
// ----- JS for 400D -----
// ----- Deletes row for 400d -----
function deleteRow2(row)
{
var i=row.parentNode.parentNode;
i.parentNode.removeChild(i);
}
// ----- Adds row to 400d -----
function insRow2()
{
var x=document.getElementById('tables2');
var new_row2 = x.rows[1].cloneNode(true);
var len = x.rows.length;
new_row2.cells[0].innerHTML = len;
var inp1 = new_row2.cells[1].getElementsByTagName('input')[0];
inp1.id += len;
inp1.value = '';
var inp2 = new_row2.cells[2].getElementsByTagName('input')[0];
inp2.id += len;
inp2.value = '';
var inputs = new_row2.querySelectorAll('input[type=text]');
for(var i=0;i<inputs.length;i++)
{
inputs[i].value='';
inputs[i].name='rows[' + len + '][' + inputs[i].dataset.name + ']';
}
x.appendChild(new_row2)
}