【发布时间】:2020-01-02 02:27:16
【问题描述】:
我正在使用 php Laravel 框架制作报告页面。我从组合框中选择选项,这些值被发送到控制器以在用于显示报告的某些查询中替换它们。
当我点击提交按钮时,页面刷新并且显示的名称是下拉列表的最后一个元素。
我的控制器:
$negocioDive = DB::table('ma_leads_reporte')
->selectRaw('NEGOCIO, year(FEC_CREACION) as AÑO')
->groupBy('NEGOCIO', 'AÑO')
->get()->toArray();
$selectFecha = DB::table('param_fecha')
->selectRaw('mesNum, mesNom')
->groupBy('mesNum', 'mesNom')
->get()->toArray();
$año = $request ->input('año');
$mes = $request -> input('mes');
$negocio = $request -> input('negocio');
//Solicitud de Cotización versus mes anterior
$mesAnt = DB::table('ma_leads_reporte')
->selectRaw('count(*) as C, day(FEC_CREACION) AS DIA, monthname(FEC_CREACION) AS MES')
->whereMonth('date_identified', '=', $mes-1)
->whereYear('date_identified', '=', $año)
->groupBy('MES', 'DIA')
->get()->toArray();
$vscont = array_column($mesAnt, 'C');
$antMes = array_column($mesAnt, 'MES');
$dia = array_column($mesAnt, 'DIA');
我的观点:
<div class="container">
<div class="row justify-content-center">
<div class="content mt-3">
<div class="animated fadeIn">
<div class="col-lg-8">
<div class="card">
<div class="card-header">
<form action="{{route('reportes')}}" method="GET" id="fecha">
{{Form::label('', 'Año')}}
<select id="año" name="año">
@foreach($negocioDive as
$negocioD)
<option value="{{$negocioD->AÑO}}"
selected="selected">{{$negocioD->AÑO}}</option>
@endforeach
</select>
{{Form::label('', 'Mes')}}
<select id="mes" name="mes">
@foreach($selectFecha as $fecha)
<option value="{{$fecha->mesNum}}" name="{{$fecha->mesNom}}">{{$fecha->mesNom}}</option>
@endforeach
</select>
{{Form::label('', 'Negocio')}}
<select id="negocio" name="negocio" >
@foreach($negocioDive as $negocioD)
<option value="{{$negocioD->NEGOCIO}}" selected="selected">{{$negocioD->NEGOCIO}}</option>
@endforeach
</select>
<button type="submit"class="btn btn-default" id="filter">Filtrar
<i class="fa fa-filter"></i>
</button>
</form>
<?php if(isset($_GET['año']) && isset($_GET['mes']) && isset($_GET['negocio'])){
echo "<h4> Año: $año | Mes: {$fecha->mesNom} | Negocio: $negocio </h4>";
}?><!--
<p id="mesJS"></p> -->
</div>
</div>
</div>
收到请求变量后,它应该显示正确的值,而不是下拉列表的最后一个索引。 我能做些什么? 下拉选项:
提交后:
【问题讨论】: