Hello everyone,
I have been stuck with this problem for a while now with no solution.
What I want to do is have a form that is populated with data from mysql table.
I want to create a select input that every time I click on one of the items in the list it will automatically change the value of the next input in the form, the order limit input. So, if I click on an item from the tag I want the “order_limit” taken from mysql db to be inserted as the value of:
<input type="number" name="amount" id="amount" class="form-control" min="1" value="1">
Items table @ MySql DB:
tbl.items: item_name,order_limit,ordered,item_department
[php]
$query = “SELECT item_name,order_limit,ordered,item_department FROM items”;
$result = $link->query($query);
echo ‘<select name=“item_name” id=“item_name” class=“selectpicker show-tick” data-placeholder=“Choose item” data-live-search=“true” onchange=“if (this.selectedIndex) amount.value=”’.json_encode($row[1]).’";">’;
while($row = $result->fetch_row())
{
if($row[1] == $row[2])
echo ‘’.$row[0].’ ‘.$row[3].’ - All items ordered’;
else
echo ‘’.$row[0].’’;
}
echo ‘’;
echo ‘’;[/php]
<script type="text/javascript">
var amount = document.getElementById('amount');
</script>
I get an error:
Notice: Undefined variable: row in...
Of course, I understand that error, but what is the solution to make this work?