Hi there,

I am relatively new to MYSQL and i have to design a database for stock for a dvd firm, this database has to link up to a website, the website is a DVD firm so the only things that needs to recorded in the database is how much stock is available.

so basically when i click buy from website it takes you to a payment page you can click confirm or decline when you hit confirm it says thank you for the purchase and takes it from the database..But how do i do this???

But i have no idea how to even start this ive been stuck with this for ages now and really have no idea what too do if anyone could help me out id be very grateful, i have webspace so can host anything.

Can anyone help me?

Dani AI

Generated

— concise, practical plan that builds on and without repeating what they already suggested.

Start with a minimal, normalized schema and an audit trail so stock changes are traceable:

products
  id INT PK
  sku VARCHAR(50)
  title VARCHAR(255)
  price DECIMAL(10,2)
  available_qty INT
  updated_at TIMESTAMP

orders
  id INT PK
  status ENUM('pending','confirmed','cancelled')
  total DECIMAL(10,2)
  payment_ref VARCHAR(100)
  created_at TIMESTAMP

order_items
  id INT PK
  order_id INT FK
  product_id INT FK
  quantity INT
  unit_price DECIMAL(10,2)

stock_movements
  id INT PK
  product_id INT FK
  delta INT
  reason VARCHAR(50)    -- e.g. "order", "refund", "manual"
  related_order INT
  created_at TIMESTAMP

A reliable runtime flow (server side only) keeps stock correct under concurrent purchases:

  • create an order row with status = "pending" when checkout starts;
  • rely on the payment gateway's server-to-server callback (IPN/webhook) to confirm payment;
  • on payment confirmation, start a DB transaction, lock the product row(s) (SELECT ... FOR UPDATE), check quantity, write the order_items and stock_movements, decrement stock, set order status = "confirmed", then commit; if stock is insufficient rollback and mark order accordingly.

Example pseudocode flow:

BEGIN;
SELECT available_qty FROM products WHERE id = ? FOR UPDATE;
IF available_qty >= qty_requested THEN
  UPDATE products SET available_qty = available_qty - qty_requested WHERE id = ?;
  INSERT INTO stock_movements(...);
  UPDATE orders SET status='confirmed' WHERE id = ?;
  COMMIT;
ELSE
  ROLLBACK;
  UPDATE orders SET status='cancelled' WHERE id = ?;
END IF;

Practical notes: use InnoDB (transactions, row locks), parameterized/prepared statements to avoid SQL injection, auto-cancel "pending" orders after a timeout to release reservations, keep an audit trail for refunds, and load-test concurrent checkouts. For : Visual Studio 2003 can connect to MySQL via MyODBC or a Connector/NET version that supports .NET 1.1 (or use ODBC).

sounds like you basically need to update the database everytime theres a purchase.

so if you have a table in mysql with the dvd name and the current quantity
a basic sql query can do this:

$sql = "UPDATE table_name SET quantity = quantity - 1 WHERE dvd = 'name of dvd'";

for that u need to do coding on ur webpage so that it connects to the database

Hello all

I am new on this site and i don't know where to click in order to be able to post. Sorry newbie for posting my message inside yours.
Can somebody tell me, Is visual Studio 2003 compatible with mysql? I am doing my final year project using VS 2003, I would also want to know How do I do the connection between the 2. Please help and Thank you in Advance.

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.