share [g+] share [fb] share [tw]
i am querying the DB as follows:
$
Code: Select all
result=mysql_query("SELECT name,items FROM mytable WHERE price='$price'");name quantity
john 10
joel 20
brian 10
how do I create an array to insert the above data using $name and $quantity as variables;
secondly,(this is a trading platform),so let's say a user wanted to buy 25 items from the data in the array,and so to achieve this the script has to take the 10 items from john and 15 from joel(that adds up to 25) and then set their items to the remaining value i.e john's items=0 and joel's items=5.how do I code this.please assist. i've tried to simplify this the best i can .thanks