Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/283.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/webpack/2.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_Laravel - Fatal编程技术网

Php 如何使用<;=-mysql

Php 如何使用<;=-mysql,php,laravel,Php,Laravel,我有一张如下的桌子。我想根据用户类型选择计数。例如,如果用户类型为10,则选择的计数应为2。这很容易得到。但当用户输入20或30时,我想选择10的计数,即2,因为20或30小于40 在我下面的查询中,当用户键入60时,它选择计数10,即(2)。我怎样才能做得更好 Number Count 10 2 40 10 60 20 控制器 $count = PriceRate::where('number','<=',$amount)-&g

我有一张如下的桌子。我想根据用户类型选择计数。例如,如果用户类型为10,则选择的计数应为2。这很容易得到。但当用户输入20或30时,我想选择10的计数,即2,因为20或30小于40

在我下面的查询中,当用户键入60时,它选择计数10,即(2)。我怎样才能做得更好

Number   Count

10         2

40         10

60         20
控制器

$count = PriceRate::where('number','<=',$amount)->first();

return $count;

$count=pricelate::where('number',”我认为这段代码将帮助您:

    $count_array = [];
    $user_type;
    $Rates= PriceRate::all();
        foreach ($Rates as $rate){
            if ($rate->number <= $user_type){
                array_push($count_array,$user);
            }
        }
$count_array=[];
$user\u类型;
$Rates=pricelate::all();
foreach($费率为$费率){
如果($rate->number尝试以下方法:

 $count = PriceRate::where('number','<=',$amount)->orderByDesc('number')->limit(1)->first();

$count=PriceRate::where('number','try this
$count=PriceRate::where('number',')@ml59,谢谢,效果不错!!