laravel - Laravel如何将数据从控制器传递到刀片
问题描述
我正在建立一个 Laravel 网站。我希望提交的表单数据运行查询并将结果插入表格格式。我正在使用 oracle DB,并且已将其连接到 Laravel。另外,我已经创建了表单,并且查询给出了正确的结果。我不能做的是成功地将结果传递到表中。
我的文件如下:
Routes.php(或较新的 laravel 版本的 web.php):
search.blade.php(带有 post 方法的表单)
--> 用户数据输入输入数据 --> 输入数据<form method="post" action="/dedomena" id="forma"> {{ csrf_field() }} <fieldset> <legend>Insert</legend> Registration Number:<br> <input type="number" name="AM" min="1000000" max="9999999"><br> <input type="submit" value="Search"> </fieldset> </form> </body>
我的控制器 (NewController.php) 运行查询。结果显示正确,但以列表格式显示。我想把它们放在表格中。
得到('上午');echo('注册号为:'); 回声($myVar);$entries = DB::table('SCC_ANSWER')->where('AM', $myVar)->get(); dd($条目);} }
我想通过另一个名为 pinakas.blade.php 的刀片,它应该如下所示。我怎样才能做到这一点?
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Results</title>
</head>
<body>
<table border="1">
<tr>
<th>AM</th>
<th>ST</th>
<th>CS</th>
<th>REGYEAR</th>
<th>REGTERMIN</th>
<th>CSYEAR</th>
<th>REGTYPE</th>
<th>REGDESCR</th>
<th>STATUS</th>
<th>STGROUP</th>
<th>SEM1</th>
<th>SEM2</th>
<th>SEM3</th>
<th>SEM4</th>
<th>SEM5</th>
<th>SEM6</th>
<th>SEM7</th>
<th>SEM8</th>
<th>SEM9</th>
<th>SEM10</th>
<th>SEM11</th>
<th>SEM12</th>
<th>SEM1B</th>
<th>SEM2B</th>
<th>SEM3B</th>
<th>SEM4B</th>
<th>SEM5B</th>
<th>SEM6B</th>
<th>SEM7B</th>
<th>SEM8B</th>
<th>SEM9B</th>
<th>SEM10B</th>
<th>SEM11B</th>
<th>SEM12B</th>
<th>SEM1P</th>
<th>SEM2P</th>
<th>SEM3P</th>
<th>SEM4P</th>
<th>SEM5P</th>
<th>SEM6P</th>
<th>SEM7P</th>
<th>SEM8P</th>
<th>SEM9P</th>
<th>SEM10P</th>
<th>SEM11P</th>
<th>SEM12P</th>
<th>TOTAL</th>
<th>TOTALB</th>
<th>TOTALP</th>
</tr>
<tr>
// <td><?php $entries?></td>
</tr>
</table>
</body>
</html>
解决方案
试试这个
public function psaxe(Request $request) {
$myVar=$request->get('AM');
$entries=DB::table('SCC_ANSWER')->where('AM',$myVar)->get();
return view('view_file_location')->with('entries' => $entries);
}
//$entries 可以在刀片页面中使用
推荐阅读
- python - docker中的pip无法打开文件'/usr/local/bin/pip':[Errno 13]权限被拒绝
- angular - 扩展面板之间的Angular Material拖放项目不起作用
- sql - 当查询按国家/地区分组时,如何为同一国家/地区返回两个相等的最大值?
- excel-formula - 如何按不包括0(零值)的最小数字创建excel列表
- c++ - 堆栈展开后不删除智能指针中的对象
- c - 设计外壳时如何处理 Control-C 信号?
- ios - 为空的 UITableView 编写条件语句
- python - 从静态网页获取特定项目时遇到问题
- sequelize.js - Sequelize migration - 定义一个空的 JSON 数组
- php - cURL 在 php shell_exec() 上没有按预期工作