Ii have been working on a shopping cart, the way my cart works is that for each item in a users cart the data is stored in a database.

So if the users has a hat and a glove there are 2 rows in my table, the rows are joined using a cart id. So each row has the same value for 'cartid'.

What I want to do is if a user enters a promo code, do updated both cart items with the promo code used.

So like

INSERT INTO cart (promocodes) VALUES ('$code') WHERE id = '$cartid'

I need to loop this query for each instance of that cartid. Any ideas on how this is done.

Thanks
-BaSk

what you need to do, i believe, is a while loop.

e.g.

<?php
$SQL = "SELECT * FROM yourtable WHERE "whatever your looking for";
$results = mysql_query($SQL);
while ($row = mysql_fetch_array($results)){
        $SQL = "Wht you want to do";
        etc etc etc
}
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.