09jesses 0 Newbie Poster

I have what I call a buildList, or better yet a Wishlist or cart. Inside this "buildList.php" is roughly 10 links, +ADD, that basically act like a button and categorized "part-1, part-2, part-3...etc. When a user chooses one button, lets say "part-1 +ADD", it links to the "contents.php" page to show all the products from the database for that specific part. When user finds a part they like they click the "+ADD" button on contents.php which on another page creates session with an array of the parts info, then I have it go back to the buildList.php and replaces the "+ADD" link button with the selected product into "part-1" category. The way I kind of have it working is :

<?php
  if (!isset($_SESSION['buildList']) || empty($_SESSION['buildList']) {
?>

//This normally shows if no session exists or if session exists but empty
// +ADD link button
<td class="add-component">
  <a href="content.php?PartType=Part1" class="add-btn"><i class="fas fa-plus"></i>ADD</a>
</td>

//If part has been added into session['buildList'] then replace +ADD link button with this
<?php
   }else{
     foreach ($_SESSION['buildList'] as $product) :
       if ($product['PartType'] == 'Part1') {
?>
<a href="pageContent.php?id=<?php echo $product['id'];?>"><img class="p-img" src="<?php echo $product['Image_thumb'];?>"/></a>
  </td>
  <td class="td-manufacturer">
    <h6>MANUFACTURER</h6>
    <p>
      <?php
        echo $product["Manufacturer"];
       ?>
     </p>
   </td>
   <td class="td-addComponent">
     <p>
       <?php 
         echo $product["Price"];
       ?>
     </p>
   </td>
   <td class="td-material">
     <h6>MATERIAL</h6>
       <p>
         <?php
           echo $product["Material"];
         ?>
       </p>
     </td>
   </tr>           
 <?php
         }
      endforeach;
    } 
  ?>

So far I can add "part-1", it does replace the "part-1" category +ADD link button with the product info like I want. But when "part-1" is added, "part-2" +ADD link button goes away and shouldn't because now I cannot get the "part-2" page to add those products. I need a way to show ALL +ADD buttons when no session exists or does exist and other categories have a product. The code above basically repeats for the other category parts. I hope this makes sense, I have tried different ways with the if statements on session variable, also searched around and didn't find this type of issue that would help. Thanks

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.