Essentially I'm building a table from mysql that has a td where users can input data manually (there is also a set default price). In another td it does a formula based on the number the user inputed multiplied by the price of the item and gives a total. Then in another td there is a button. On button press it will add a new row to a table above if that item doesn't already exist in the table. If it does exist it will add on to the existing data in the table.
So far I have the drop table being created already using this code:
Code:
<button class="btn btn-info" data-toggle="collapse" data-target="#common">Common</button>
<div id="common" class="collapse in">
<table class="table table-bordered">
<thead>
<tr>
<th>Item</th>
<th>Quantity</th>
<th>Rarity</th>
<th>Price</th>
<th>Add Drop</th>
</tr>
</thead>
<tbody>
<?php
$sql = mysql_query("SELECT *
FROM `monster_items` INNER JOIN `items`
ON monster_items.item_id = items.item_id
WHERE monster_id = '$npcid' AND rarity = 'Common'");
if($sql)
{
while ($result = mysql_fetch_assoc($sql))
{
echo '<tr><td>'.$result['item_name'].'</td>';
echo '<td class="col-xs-2"><input onchange="getPrice" id="a'.$result['id'].'" type="number" value="'.$result['quantity'].'" class="form-control col-xs-2 input-sm"></td>';
echo '<td>'.$result['rarity'].'</td>';
$final_price = $result['sell_average']*$result['quantity'];
echo '<td>'.number_format($final_price).'</td>';
echo '<td><button id="'.$result['item_id'].'" class="btn-xs btn-success">Add Drop</button></td>';
}
}
?>
</tbody>
</table>
</div>
This code creates this:
The part I need help with is the user input doesn't not actually update the data (I assume I need some sort of jquery/javascript code to update that?)
After I get the first part done, I'll want to make the button functional.
Here is the code for the table that data will be appended to:
Code:
<table class="table table-bordered">
<div class="col-sm-12 text-center">
<h4>
Total Drops Received
</h4>
</div>
<thead>
<tr>
<td colspan="1">Total Price:</td>
<td colspan="2">999,999,999 GP</td>
</tr>
<tr>
<th>Item</th>
<th>Quantity Received</th>
<th>Price</th>
</tr>
</thead>
<tbody>
<tr>
<td>Pure Essence</td>
<td>600</td>
<td>4800</td>
</tr>
</tbody>
</table>
However if an item already exists in that table, let's say 600 pure essence is in the table, and you hit the button to add pure ess, it will then be 1,200 and the correct price.
If anyone is willing to help me with this it will be much appreciated! At least a push in the right direction would be awesome! I'm still a beginner programmer and have been self teaching myself.