1 and startday<='".$nowyear."-".$nowmonth."-".$nowday."' and expireday>='".$nowyear."-".$nowmonth."-".$nowday."' and customcode='".$q."' "; $result = $db->query($sql); while ($row = $db->fetch_array($result)) { $customcode = $row["customcode"]; $_SESSION["couponcode"]=$row["customcode"]; $a[] = $customcode; $b[] = $row["fee1"]*$_SESSION['currency']; $fee = $row["fee1"]*$_SESSION['currency']; } $hint = ""; // lookup all hints from array if $q is different from "" if ($q !== "" ) { $q = strtolower($q); $len=strlen($q); $counter=0; $_SESSION["coupondiscount"]=""; foreach($a as $name) { if (stristr($q, substr($name, 0, $len))) { if ($hint == "") { $_SESSION["coupondiscount"]=$b[$counter]; $promoCode=""; $hint = " ( ".$_SESSION['curr']." ".$fee." Discounted value will be shown on the next step )"; } else { } } $counter++; } } echo $hint === "" ? "Invalid code" : $hint; ?>