Adding Items to a cart system

Hi Guys,

I’m having a bit of an issue figuring how I can do this. Basically I have a catalogue page that will display a list of all my products and a page that lists all the products (courses) a signed in user has selected. Now for my products page, I basically just have a table and populate that from a recordset I created from my catalogue table. Next I check if the user table already has that entry, if it does not I add a “Add” button and if they do have that entry I add a “remove” button.

The problem is this: There is no way for me to know which button from the list that was actually pushed because the id is all the same. Is there a way for me to change my code so that my button id matches say my catalogueID so in my POST i know which button was pushed.

Also if you see a better way I can do this I am glad to hear any suggestions, I do howerver need to keep all products on one page and don’t want a description page. I need them to be able to go to catalogue and add everything there. Also I already am passing data to the URL of this page and would want to avoid passing other data to the same page.

Here is my code:
[php]

<?php do { ?> <?php } while ($row_rsMainCatalogue = mysql_fetch_assoc($rsMainCatalogue)); ?>
Course Name Course Description Software  
<?php echo $row_rsMainCatalogue['courseName']; ?> <?php echo $row_rsMainCatalogue['courseDescription']; ?> <?php echo $row_rsMainCatalogue['softwareName']; ?> <?php do { if($row_rsUserCourses['courseID'] = $row_rsMainCatalogue['courseID']){ $varAdd = false; } else { $varAdd = true; } } while($rowrsUserCourses = mysql_fetch_assoc($rsUserCourses)); if ($varAdd = true) { echo ""; } else { echo ""; } ?>
[/php]

Nevermind, I was able to solve it. It was simple and I should have seen it beforehand.

I just added the information to my echo to add the courseID which is my primary key in the button ID field.

code:

[php]echo “<input type=“submit” name=“add” id=”" .$row_rsMainCatalogue[‘courseID’]."" value=“Add” />";[/php]

Always nice to solve it yourself! Congrats!

Sponsor our Newsletter | Privacy Policy | Terms of Service