I have made a favorites function on my site that someone can choose different items that go together and save it as a favorite package in their account. All items are saved in a favorite table with a favorite ID number. Anything that has the same ID number go together. This will save under the customer that is logged in.
I am trying to import this array into a PHP page and display the items graphicly in a lightbox type look, but have been running into a lot of trouble combining them together to display them properly.
The array and php code are below. The array is generated from a SQL query. The items of array [0] and [1] need to be combined together in such a way that I can show the images from each one together (the images actually go on top of each other to make it look like a package.
Here is a link to the page so you get an idea: https://www.viva-cards.com/products/package-designer you will not be able to see the favorite function unless you log-in though
I basically need to combine the same fav_seq ids together, but still be able to differentiate itm_id, offer_id, inv_type_id, , inv_thumbnail_url and offer_description, as they have different images and such that go with them. I have been hitting my head to a brick wall on this. Is there a way to do this on the php page, or do I have to do it at the SQL query stage? What am I doing wrong?
The following is the code of the array:
[0] => Array
(
[entity_id] => 6
[itm_id] => 81
[fav_seq] => 1
[offer_id] => 1
[inv_css_tag] =>
[inv_type_id] => TYPE1
[inv_thumbnail_url] => image1-thumb.png
[offer_description] => Offer1
)
[1] => Array
(
[entity_id] => 6
[itm_id] => 198
[fav_seq] => 1
[offer_id] => 1
[inv_css_tag] => csstag
[inv_type_id] => TYPE2
[inv_thumbnail_url] => image2-thumb.jpg
[offer_description] => Offer2
)
[2] => Array
(
[entity_id] => 6
[itm_id] => 810
[fav_seq] => 2
[offer_id] => 4
[inv_css_tag] =>
[inv_type_id] => TYPE1
[inv_thumbnail_url] => image3-thumb.png
[offer_description] => Offer4
)
[3] => Array
(
[entity_id] => 6
[itm_id] => 98
[fav_seq] => 2
[offer_id] => 4
[inv_css_tag] => csstag
[inv_type_id] => TYPE2
[inv_thumbnail_url] => image4-thumb.jpg
[offer_description] => Offer4
)
This is the code I am using on the php page to generate the display:
<div>
<h2>Favorites Saved</h2>
<?php
foreach($this->favorite_seq as $favorites){
if(empty($favorites['fav_seq'])){
// Nothing
?>
<?php }else {?>
<div id="favoritesThumbnailWrapper"> <!-- For TYPE1 -->
<div id="favoritesReferralThumb" class="cardPositionMiddle1">
<img src="<?= $this->inventory_url . $favorites['inv_thumbnail_url'];?>">
</div>
<div id="favoritesPresentationThumb"> <!-- For TYPE2 -->
<img src="<?= $this->inventory_url . $favorites['inv_thumbnail_url'];?>">
</div>
<div id="favoritesOffer"> <!-- For OFFER DESCRIPTION -->
<span><?= $favorites['offer_description'];?></span>
</div>
</div>
<?php
}
}
?>