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[0]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!

Recommended Answers

All 2 Replies

Member Avatar for diafol

You haven't received a reply for 11 hours - that may be due to the fact that your problem is difficult to follow. I read it twice and was still unsure. Perhaps if you include your code and be a little more concise with the (1) explanation of the system and (2) your requirements.

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?

always operate server-side, you want a stable reliable source of accurate data so everything pulls and writes to one place. And like Ardav says it is very hard to follow make some flow chart or show an example.

  1. Buy now -> reserve product
  2. Product tagged as reserved in DB
  3. Product paid for and shipped -> tag sold | Product not paid for after 3 days -> remove reservation
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.