Create a view with your table, and pass data to it
Jan 23, 2019
14
Level 1
Display query results in table form
Hi guys!
I have created a form which accepts a user number input and after submitting it, the user receives some personal data from a local oracle db (which made it to connect to laravel thanks to you!). The query runs fine, but the results appear in list (I use the dd($entries) at the 3rd excerpt). How can I edit my code to appear in a simple table format (simple cells in one line)?
My code excerpts are as below:
- routes.php (or web.php for newer laravel version)
<?php
Route::get('/search', 'PagesController@search'); //find student data!
Route::post('/dedomena', 'NewController@psaxe');
- search.blade.php (it's the completion form)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<!--<link rel="stylesheet" type="text/css" href="form_style.css"> -->
<title>Εισαγωγή Δεδομένων Χρήστη</title>
</head>
<body>
Εισαγωγή Δεδομένων
<form method="post" action="/dedomena" id="forma">
{{csrf_field()}}
<fieldset>
<legend>Εισαγωγή</legend>
Αριθμός Μητρώου:<br>
<input type="number" name="AM" min="1000000" max="9999999"><br>
<input type="submit" value="Αναζήτηση">
</fieldset>
</form>
</body>
</html>
- And finally the NewController.php
<?php namespace App\Http\Controllers;
use Illuminate\Http\Request;
use DB;
class NewController extends Controller
public function psaxe(Request $request)
{
$myVar = $request->get('AM');
echo('Αποτελέσματα για τον φοιτητή με ΑΜ: ');
echo($myVar);
$entries = DB::table('SCC_ANSWER')->where('AM', $myVar)->get();
dd($entries);
}
}
Level 20
Ok, so just delete the dd( line in controller, and in the view, take everything lower case like $entries1->am. It should work.
1 like
Please or to participate in this conversation.