Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/57.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在php/mysql中制作价格范围系统?_Php_Mysql - Fatal编程技术网

如何在php/mysql中制作价格范围系统?

如何在php/mysql中制作价格范围系统?,php,mysql,Php,Mysql,我想使用php/mysql为产品表创建一个价格范围系统 这是一张桌子 以下是产品表: 这就是我想要实现的目标 if we select price from 0 - 30 (1) Only product of that range should display if we select price from 100 - 250 (1) Only product of that range should display and so on... 如何使用php和mysql实现这一

我想使用php/mysql为产品表创建一个价格范围系统

这是一张桌子

以下是产品表:

这就是我想要实现的目标

if we select price 

from 0 - 30 (1) Only product of that range should display 

if we select price 
from 100 - 250 (1) Only product of that range should display 

and so on...
如何使用php和mysql实现这一点?任何提示、指导都会很有帮助。对于一个php新手,我应该如何承担这项任务。

使用MySQL:-

使用


您需要使用Mysql的Between关键字。Between关键字检查范围之间的值。 使用此查询。根据需要更改值

假设您的下限为$price1,上限为price2


这里我将解释price ranger如何在select查询中工作

我会这样问的

Select * from product where price between $lower and $higher;
$lower是价格范围的最小值,并且

美元越高,价格范围的价值越高


您应该首先了解基本的MySQL查询。。。不管怎样,它可能是这样的:从product_表中选择*,其中price>0,price<30@TanuelMategi:yesss..谢谢..我知道我应该对每个选项使用BETWEEN,如下所示:对于0-30之间的产品价格,请从产品表中选择*30; 对于50-100之间的价格,从产品表中选择*,其中价格介于50-100之间;等等……对吗?:谢谢……似乎很简单……我会尝试,然后再联系你。我应该在每个选项中使用中间值,如下所示:对于0-30之间的产品价格,从产品表中选择*,其中价格在0-30之间;对于50-100之间的价格,从产品表中选择*,其中价格介于50-100之间;等等……对吗?谢谢……看起来很简单……我会尽力回到你身边。
select * from product where price between 0 and 30 
select * from product where price between 100 and 250 
SELECT *
FROM product table
WHERE price 
BETWEEN
0 AND 30;// pass your range here
Select * from product where price between $price1 and $price2
Select * from product where price between $lower and $higher;