Hope I can explain this as clear as possible:
I have a page (info.php) where cards (coupons) are claimed, these cards each have a product id. In the page, if a user selects the "claim" button, the card gets saved to another (list-claimed.php). This other page displays all cards claimed by the user within the timespan of 48 hours. Of course it only shows the claimed cards of the certain user that is logged in.
The table in the screenshot is where i get the data from (SELECT SQL)
Here is a snippet of the code from list-claimed.php to display the claimed cards:
<h2 class="bold_font text-align-center">LIST OF CLAIMED CARDS</h2><br>
<?php
$i = 0;
foreach($lstOrders as $rowOrder) {
if ($rowOrder['expirationdate'] > date("Y-m-d H:i:s")){
?>
<div class="col-md-4 spacer">
<div class="col-md-12">
<?php
$productid = $rowOrder['productid'];
$rowProduct = $mcProduct->SelectObj_ProductId($db, $productid);
$rowSelect = $mcOrder->SelectLst($db, $pageNum, $limit);
?>
</div>
Now to the main concern, in my info.php I would like to show the words "You have already claimed this coupon" if the card is currently in list-claimed.php. In other words, the cards that meet the condition of getting claimed by the user within the 48 hour period.
<?php
foreach($lstOrders as $rowOrder) {
if ($rowOrder['expirationdate'] < date("Y-m-d H:i:s")) { ?>
<div class="col-md-12 text-align-center">
<h3 class="color-red">You have already claimed this coupon.</h3>
</div>
<?php } }
How can I modify the php code to get what I need?
My goal: (pseudocode)
if ($productid is in list-claimed.php){
<div class="col-md-12 text-align-center">
<h3 class="color-red">You have already claimed this coupon.</h3>
</div>
}
Any help will be appreciated, thanks!
UPDATE:
Solved this issue using an array to check if the productid of the coupon is in the list-claimed.php page using "in_array".
<?php
foreach($lstInfo as $rowOrder) {
if (isset($rowOrder['productid']) && ($rowOrder['expirationdate'] > date("Y-m-d H:i:s"))) {
//array (visually seen in list-claimed.php)
$claimed = array($rowOrder['productid']);
//check if current card exists in claimed array
if (in_array($rowProduct['productid'] , $claimed) ) {
?>
<div class="col-md-12 text-align-center">
<h3 class="color-red">You have already claimed this coupon.</h3>
</div>
<?php } } }