if ($uRes && mysqli_num_rows($uRes) > 0) {
$uRow = mysqli_fetch_assoc($uRes);
$userTitle = $uRow['title'];
$userName = $uRow['name'];
}
}
$favorites = [];
if (isset($_SESSION['user_id'])) {
$uid = (int) $_SESSION['user_id'];
$wSql = "SELECT product_id FROM user_wishlist WHERE user_id = $uid";
$wRes = mysqli_query($conn, $wSql);
if ($wRes) {
while ($wRow = mysqli_fetch_assoc($wRes)) {
$favorites[] = (int) $wRow['product_id'];
}
}
} else {
if (!empty($_SESSION['wishlist']) && is_array($_SESSION['wishlist'])) {
$favorites = array_map('intval', $_SESSION['wishlist']);
}
}
$products = [];
$sql = "SELECT * FROM products_table WHERE delete_flag = 0 ORDER BY id ASC";
$result = mysqli_query($conn, $sql);
if ($result) {
while ($row = mysqli_fetch_assoc($result)) {
$products[] = $row;
}
}
function getCategorySlug($type)
{
$type = strtolower(trim($type));
if ($type === 'green tea')
return 'green-tea';
if ($type === 'herbal & wellness')
return 'herbal-tea';
if ($type === 'black tea')
return 'black-tea';
return 'other';
}
$contact = mysqli_query($conn, "SELECT * FROM website_table WHERE delete_flag = 0 ORDER BY id DESC ");
?>