Results 1 to 24 of 24
May 3, 2012, 10:40 #1
- Join Date
- Dec 2009
- 0 Post(s)
- 0 Thread(s)
Conditional echo on update field?
OK. I have an Ajax getproduct() function that calls getproduct.php page with the id of li tag elements from multiple uls in #sidebar div. The id of each li tag references a table in the database as '$q=$_GET["q"]'. All the rows in the tables called are the same and each contains a field called 'sold' which is empty. When The client purchases an item from a category / ul tag that only has one original item the database field for that item/sold has to be updated so that that item and row is echoed as sold!. The idea being that the item/row will not be removed from the database until confirmation or receipt of the item by the client. Other clients will be able to view the item sold but won't be able to purchase it for some time untill the purchaser receives the item.
I'm guessing I'll have to add a new Ajax updateproduct() function that calls updateproduct.php. I've added 'Sold!' to the 'sold' field and can see the result echoed and have bookmarked the sql as 'updatesold' and can create the updateproduct.php query. The problem is that the echoed row of the sold item contains select quantity tag with options length 1 that still shows up as 1 when another client downloads the page as well as the button still having innerHTML of 'Buy Now!'. The purchasers select quantity options is converted to 'Sold!' and that buttons innerHTML shows up as 'Sold!' but the next client won't because only the sold field is updated. I need to know if it is better to update the whole row in phpmyadmin and copy the new query to echo the complete update or try to catch the 'sold' innerText' clientside and alter the button and select quantity options from there? Any advice greatly appreciated. I might be wrong about needing a separatee updateproduct() function and updateproduct.php page and the conditions can be added to the original getproduct() function and getproduct.php? That would be a lot easier!: