you mix up php and javascript here:
echo '<li onclick="updateBasket('.$i.','+value['basketID'].')"><?= $i ?></li>';
you are still in php context, when using <?= $i ?>
the value['basketId'] has to be evaluated in JS? dont you have that basketId variable present in php?
//this just echoes out `value['basketId']`, but i am not sure it will work as you expect
echo '<li onclick="updateBasket(' . $i . ', value[\'basketID\'])">' . $i . '</li>';
//this should work when you have the `$basketId` in php
echo '<li onclick="updateBasket(' . $i . ', ' . $basketId . ')">' . $i . '</li>';
but i strongly suggest to refactor all of that code, you are in JS context printing HTML using PHP that prints HTML and JS 🤯
