0

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

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by whiteyoh
0

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
}
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.