Php 使用下拉菜单Laravel中的变量填充表

Php 使用下拉菜单Laravel中的变量填充表,php,mysql,laravel,Php,Mysql,Laravel,我有一个页面,其中包含一个下拉列表,其内容(过滤器)是DB查询的结果,一个表也填充了DB查询的结果。我想做的是选择下拉列表中的一个选项,一旦选择,这个选项应该作为变量传递回表的sql查询,以便可以使用这些新过滤器显示表 模型1(表): 模型2(下拉列表): 控制器: class WebController extends BaseController { public function getSql_Test() { $topPages

我有一个页面,其中包含一个下拉列表,其内容(过滤器)是DB查询的结果,一个表也填充了DB查询的结果。我想做的是选择下拉列表中的一个选项,一旦选择,这个选项应该作为变量传递回表的sql查询,以便可以使用这些新过滤器显示表

模型1(表):

模型2(下拉列表):

控制器:

  class WebController extends BaseController {
        public function getSql_Test() {
                    $topPages = TopPage::webmasters();
                $filters = Dropdown::getFilters();
                        return View::make('tools.show',['TopPage'=>$topPages],
                      ['Dropdown'=>$filters]);
视图:

{{Form::open()}

{{Form::select('filt',$Dropdown,2)}

日期 页 分类 @foreach($TopPage作为$TopPage) {{$topPages->date} {{$topPages->page} {{$topPages->categorie} @endforeach
{{Form::close()}}

任何帮助都将不胜感激。

您是否忘记在视图中包含submit以便它可以调用筛选器

{{ Form::submit('Search') }} 
在表单操作中,您需要引用函数

Form::open(array('action' => 'Controller@method'))
Laravel文档


您好,谢谢您的输入。我已经包括提交。我一直想知道如何将下拉列表中的选定选项返回到sql查询中的变量中。你知道怎么做吗?你需要做一个有参数的函数。然后在您的表单操作中传递函数的参数,该参数将是您的下拉值。但是,请理解,您可以使用查询字符串来完成相同的任务。例如www.questions.com/questions?=未回答
  {{ Form::open() }}
    <p></p>
    <table class='liste' style='margin-left: 0px;' cellpadding='5'>
    {{ Form::select('filt', $Dropdown, 2) }}

    <p></p> 
    <tr>
           <td style='background-color: #426bb3; color: white; font-weight: bold; width:16%;'>Date</td>
        <td align='left' style='background-color: #426bb3; color: white; font-weight: bold; width:12%;'>Page</td>
        <td align='left' style='background-color: #426bb3; color: white; font-weight: bold; width:12%;'>Categorie</td>
    </tr>

        @foreach($TopPage as $topPages)
    <tr>
        <td> {{$topPages->date}} </td>              
        <td> {{$topPages->page}} </td>        
        <td> {{$topPages->categorie}} </td> 
    </tr>
    @endforeach 

        </table><br>  

   {{ Form::close() }}  
{{ Form::submit('Search') }} 
Form::open(array('action' => 'Controller@method'))