This is my code for my the current database populated table. i have found a previous javascript code to help me sum values from multiple checlboxes.
the values i want summed are only from my Asset_Cost
<body>
<table cellpadding="0" cellspacing="0" border="0" id="table" class="sortable">
<thead>
<tr>
<th><h3>Asset ID</h3></th>
<th><h3>Vendor</h3></th>
<th><h3>Hardware </h3></th>
<th><h3>Cost</h3></th>
<th><h3>Purchase Date</h3></th>
<th><h3>Select Cost</h3></th>
</tr>
</thead>
<tbody>
<?php
mysql_connect("localhost","seetoh88_mp04","tneme16");
mysql_select_db("seetoh88_mp04");
$result = mysql_query("SELECT * FROM Asset");
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['Asset_ID']."</td>";
echo "<td>" . $row['Vendor_Name'] . "</td>";
echo "<td>" . $row['Hardware_ID'] . "</td>";
echo "<td>" . $row['Asset_Cost'] . "</td>";
echo "<td>" . $row['DateOfPurchase'] . "</td>";
echo "</tr>";
}
echo "</table>";
. i want to to integrate the checkbox sum from this code
<?php
include('connect1.php');
$result = $db->prepare("SELECT * FROM Asset");
$result->bindParam(':userid', $res);
$result->execute();
for($i=0; $row = $result->fetch(); $i++){
?>
<INPUT TYPE="checkbox" NAME="items[]" value="<?php echo $row['Asset_Cost'] ?>" id="sum_m_<?php echo $i ?>" onclick="UpdateCost()">
<td>
<?php echo $row['Asset_ID'] ?>
<?php echo $row['Vendor_Name'] ?>
<?php echo $row['Hardware_ID'] ?>
<?php echo $row['Asset_Cost'] ?>
</td>
<br>
<?php
}
?>
<br>
Total Cost : <input type="text" name="sen" id="totalcost" value="">
Aucun commentaire:
Enregistrer un commentaire