Here is the web page:
Update data and ID is showing while other data such as customer name, phone, etc are not showing.
CustomersController.php
public function index()
{
$customers = Customer::all();
return view('customers.index', ['customers' => $customers]);
}
index.blade.php
#extends('layouts.app')
#section('content')
<h1>Customers</h1>
#if(count($customers)>0)
<table class="table">
<thead>
<tr>
<th scope="col">ID</th>
<th scope="col">Name</th>
<th scope="col">Email</th>
<th scope="col">Phone</th>
<th scope="col">Address</th>
<th scope="col">Updated on</th>
</tr>
</thead>
#foreach($customers as $customer)
<tbody>
<tr>
<th scope="row">{{$customer->id}}</th>
<td>{{$customer->name}}</td>
<td>{{$customer->email}}</td>
<td>{{$customer->phone}}</td>
<td>{{$customer->add}}</td>
<td>{{$customer->updated_at}}</td>
</tr>
#endforeach
#else
#endif
#endsection
You didn't close <table> and <tbody>, and you placed <tbody> inside the loop (it should only appear once)
Try this:
#extends('layouts.app')
#section('content')
<h1>Customers</h1>
#if(count($customers)>0)
<table class="table">
<thead>
<tr>
<th scope="col">ID</th>
<th scope="col">Name</th>
<th scope="col">Email</th>
<th scope="col">Phone</th>
<th scope="col">Address</th>
<th scope="col">Updated on</th>
</tr>
</thead>
<tbody>
#foreach($customers as $customer)
<tr>
<td>{{$customer->id}}</td>
<td>{{$customer->name}}</td>
<td>{{$customer->email}}</td>
<td>{{$customer->phone}}</td>
<td>{{$customer->add}}</td>
<td>{{$customer->updated_at}}</td>
</tr>
#endforeach
</tbody>
</table>
#else
#endif
#endsection
You didn't close your table tag and <tbody> tag and <tbody> opening tag should be start before foreach loop.
Related
In this image this table is based on my databse "Employee" table. there is 2 part. 1st part is from "#" column to "employee type" column. 2nd part is "Leave Type" Column. This column infromation will come from "LeaveType" Table. No I want to create different type leavetype for 1 employee. It mean I want to create subrow for each parent row in this column. But I can't
here is my incomplete table code in blade file.
<table class="table table-bordered mb-0" id="myTable">
<thead class="bg-orange">
<tr class="text-light">
<th >#</th>
<th >Employee Name</th>
<th >Employee Id</th>
<th >Employee Type</th>
<th >Leave Type</th>
<th >Entitled</th>
<th >Used Leave</th>
<th >Balance</th>
</tr>
</thead>
<tbody>
#foreach($users as $user)
<tr>
<th scope="row">{{$loop->iteration}}</th>
<td>
{{$user->name}} <br>
#foreach($designations as $designation)
#if($designation->id === $user->designationId)
{{$designation->designationName}}
<br>
#endif
#endforeach
#foreach($departments as $department)
#if($department->id === $user->departmentId)
{{$department->departmentName}}
#endif
#endforeach
</td>
<td>{{$user->employeeId}}</td>
#foreach($designations as $designation)
#if($designation->id === $user->designationId)
<td>{{$designation->attendanceType}}</td>
<br>
#endif
#endforeach
<td>
</td>
</tr>
#endforeach
</tbody>
</table>
i have this code in my blade.php file
<table class="table table-success table-striped">
<thead>
<tr>
<th scope="col">ID</th>
<th scope="col">Username</th>
<th scope="col">Password</th>
<th scope="col">Email</th>
</tr>
<tbody>
#foreach($users as $user)
<tr>
<th scope="row">{{$user->ID}}</th>
<td>{{$user->username}}</td>
<td>{{$user->password}}</td>
<td>{{$user->email}}</td>
</tr>
#endforeach
</tbody>
</table>
and when i call my blade.php file to view a html page, i see only the emails from data.
This is the view when i run a dd($user) command.
This is a Html page
Looks like you got names wrong. Try this:
<table class="table table-success table-striped">
<thead>
<tr>
<th scope="col">ID</th>
<th scope="col">Username</th>
<th scope="col">Password</th>
<th scope="col">Email</th>
</tr>
<tbody>
<?php
foreach($users as $user){
echo "<tr>
<th scope='row'>".$user['ID']."</th>
<td>".$user['user_login']."</td>
<td>".$user['user_pass']."</td>
<td>".$user['user_email']."</td>
</tr>";}
?>
</tbody>
</table>
I installed TinyMCE editor on my Laravel application. I want to write HTML in my TinyMCE, like or per example.
Here is the code I put in TinyMCE :
<table class="table table-dark">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">First</th>
<th scope="col">Last</th>
<th scope="col">Handle</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">1</th>
<td>Mark</td>
<td>Otto</td>
<td>#mdo</td>
</tr>
<tr>
<th scope="row">2</th>
<td>Jacob</td>
<td>Thornton</td>
<td>#fat</td>
</tr>
<tr>
<th scope="row">3</th>
<td>Larry</td>
<td>the Bird</td>
<td>#twitter</td>
</tr>
</tbody>
</table>
So I dit it and I print the result like that :
<p>{!!html_entity_decode($vpn->intro)!!}</p>
Here is the result :
Can you help me to solve the problem please ?
<table> does not allowed to be printed inside <p>, Use <div> instead.
<div>
{!!html_entity_decode($vpn->intro)!!}
</div>
Here you can find out why.
Please I want to automatically number each row when data is displayed from the database. Something like this
<table class="table">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">First</th>
<th scope="col">Last</th>
<th scope="col">Handle</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">1</th>
<td>Mark</td>
<td>Otto</td>
<td>#mdo</td>
</tr>
<tr>
<th scope="row">2</th>
<td>Jacob</td>
<td>Thornton</td>
<td>#fat</td>
</tr>
<tr>
<th scope="row">3</th>
<td>Larry</td>
<td>the Bird</td>
<td>#twitter</td>
</tr>
</tbody>
</table>
so each row is numbered in ascending order from 1 to n depending on the data available in the database. How do I properly do that. Any Help please am new in laravel
If you are using blade, the laravel's automatically generated $loop variable might help. Like this:
<table class="table">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">First</th>
<th scope="col">Last</th>
<th scope="col">Handle</th>
</tr>
</thead>
<tbody>
#foreach($items as $item)
<tr>
<th scope="row">{{ $loop->iteration }}</th>
<td>{{ $item->first_name }}</td>
<td>{{ $item->last_name }}</td>
<td>#{{ $item->username }}</td>
</tr>
#endforeach
</tbody>
</table>
You can find documentation here: https://laravel.com/docs/8.x/blade#the-loop-variable
I have the following html code :
<table>
<tbody>
<tr>
<th >operatore</th>
<td>3</td>
<td>4</td>
<td>5</td>
<tr/>
<tr>
<th >operatore</th>
<td>6</td>
<td>7</td>
<td>8</td>
<tr/>
</tbody>
</table>
I would like to insert the following tags after the TABLE tag:
<thead>
<tr>
<th >Nome IT</th>
<th >a</th>
<th >b</th>
<th >c</th>
</tr>
</thead>
so I'd like to get:
<table>
<thead>
<tr>
<th >Nome IT</th>
<th >a</th>
<th >b</th>
<th >c</th>
</tr>
</thead>
<tbody>
<tr>
.....
I created the following code for THEAD and succeeded:
$thead = $dom_ods->createElement("thead", "");
$ods2_tmp->insertBefore($thead, $ods2_tmp->firstChild);
$dom_ods->saveHTML();
while I can't for the others, how can I proceed?