【发布时间】:2014-11-28 15:59:09
【问题描述】:
我正在制作一个简单的搜索引擎,如果从下拉列表中选择的列表与数据库中“destinationto”列中的列表匹配,那么它将获取该行中的所有项目。但是当我点击查找按钮时,它不会从数据库中返回任何项目。它会给我一个空数组。
object(Illuminate\Database\Eloquent\Collection)[141]
protected 'items' =>
array (size=0)
empty
我做错了什么?
这里是sn-ps
OnewayflightControllers.php:
public function onewayflightresults()
{
$destinationto = Input::get('destinationto');
$results = Oneways::where('destinationto','=',$destinationto)->get();
var_dump($results);
}
public function onewayflight()
{
$onewaysfrom = DB::table('oneways')->distinct()->lists('destinationfrom');
$onewaysto = DB::table('oneways')->distinct()->lists('destinationto');
return View::make('content.onewayflight')->with(['destinationfrom'=>$onewaysfrom,'destinationto'=>$onewaysto]);
}
onewayflight.blade.php:
{{ Form::label('destinationto','To: ') }}
{{ Form::select('destinationto', $destinationto)}}
【问题讨论】:
-
目前您在填写表格时似乎没有
destinationto值中的行。否则,请告诉我们您填写的内容、$destinationto中的var_dump是什么以及您的表格中有哪些数据 -
@MarcinNabiałek 先生,我已经编辑了我的问题。我在所有东西上都尝试了 var_dump,只有 $destinationto 没有给我任何结果。我可能犯了什么错误?
标签: php laravel laravel-4 blade laravel-form