首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >我怎样才能确保$ ". $discount_offer_on_totals。“也是基于站点url的。

我怎样才能确保$ ". $discount_offer_on_totals。“也是基于站点url的。
EN

Stack Overflow用户
提问于 2020-08-23 17:41:16
回答 1查看 33关注 0票数 0

我有多个网站使用相同的折扣数据库表。但是,无论使用哪个网站,当if语句为true时,return部分都会返回第一个url的值。我怎样才能确保$ ". $discount_offer_on_totals。“也是基于站点url的。

代码语言:javascript
运行
复制
list($discount_offer_on_totals) = mysqli_fetch_row(mysqli_query($connect,"select discount_offer from orders_discounts")); 
    if ( $total < $discount_offer_on_totals ) {
    return "Order total must be $ ". $discount_offer_on_totals." or more to qualify for discount!";
    }

Discounts Table

EN

回答 1

Stack Overflow用户

发布于 2020-08-23 18:00:49

您可以在查询中使用where条件

代码语言:javascript
运行
复制
$stmt = mysqli_prepare($connect, "SELECT discount_offer FROM orders_discounts WHERE url = ? ");
mysqli_stmt_bind_param($stmt, "s", $_SERVER['SERVER_NAME']);
mysqli_stmt_execute($stmt);
$result = mysqli_stmt_get_result($stmt);
$row = mysqli_fetch_row($result);
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63545509

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档