HTML in TinyMCE (Laravel) show errors - php

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.

Related

Does not display data from database at blade.php file

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>

How to automatically number each row in a table in laravel?

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

PHP: insert tag in DomDocument

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?

How to break css column property if content is too long

I am trying to test out having multiple tables with various types of rows displayed on the webpage.
I am then using CSS Columns property to break the content in 4 columns.
My problem when the column finish; it continues the content on the next column. The tables I have can have multiple rows some have 10, some have 5 etc...
What I wanted to do is get page look a bit neater. If you see the picture I have attached below - I have some tables going to the next column.
What is the best practice or how to make this webpage look like a nice grid?
Here is how it looks
Here is the code:
<div class="row test">
<div class="panel panel-success">
<div class="panel-heading">Customer Test</div>
<div class="panel-body">
<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>
</div>
</div>
<div class="panel panel-success">
<div class="panel-heading">Customer Test</div>
<div class="panel-body">
<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>
</div>
</div>
<div class="panel panel-success">
<div class="panel-heading">Customer Test</div>
<div class="panel-body">
<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>
</div>
</div>
<div class="panel panel-success">
<div class="panel-heading">Customer Test</div>
<div class="panel-body">
<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>
</div>
</div>
<div class="panel panel-success">
<div class="panel-heading">Customer Test</div>
<div class="panel-body">
<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>
</div>
</div>
<div class="panel panel-success">
<div class="panel-heading">Customer Test</div>
<div class="panel-body">
<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>
</div>
</div>
<div class="panel panel-success">
<div class="panel-heading">Customer Test</div>
<div class="panel-body">
<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">2</th>
<td>Jacob</td>
<td>Thornton</td>
<td>#fat</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>
</div>
</div>
<div class="panel panel-success">
<div class="panel-heading">Customer Test</div>
<div class="panel-body">
<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>
<tr>
<th scope="row">3</th>
<td>Larry</td>
<td>the Bird</td>
<td>#twitter</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</body>
</html>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<!-- Bootstrap Stles -->
<script src="bootstrap-3.4.1/js/bootstrap.js"></script>
<script src="bootstrap-3.4.1/js/bootstrap.min.js"></script>
<style>
.navbar{
background-color: #EB4646;
border-radius: 0px;
color: white;
padding: 0.2%;
}
.test {
-webkit-column-count: 5;
-moz-column-count: 5;
column-count: 5;
</style>
Edit Answer
How it looks again

Why datagrid_data1.json data can not appear

In my project, i use easyui-datagrid.
Here is my html code:
<tr>
<td style="width:10%" colspan="2">attachment</td>
<td style="width:90%" colspan="18">
<table class="easyui-datagrid" data-options="url:'datagrid_data1.json',method:'get'" title="" style="width:100%">
<thead>
<tr>
<th data-options="field:'ck',checkbox:true"></th>
<th data-options="field:'name',align:'center'">filename</th>
</tr>
</thead>
</table>
</td>
</tr>
The code of datagrid_data1.json:
{"total":2,"rows":[
{"name":"1.jpg"},
{"name":"123.jpg"}
]}
But unfortunately, I works fail. Two names of 1.jpg and 123.jpg can not appear. Who can help me?

Categories