1
I have a table that is composed of values that are pulled from the database....
This table has the predefined size, and it turns out that when the value pulled from the bank is greater than the cell, it resizes and messes up everything...
I want to know if you can do this:
Code
<div class="tabela-clientes" >
<table id="mytable">
<tr>
<td style="width: 200px">
Nome
</td>
<td style="width: 200px">
Empresa
</td>
<td style="width: 90px">
Telefone
</td>
<td style="width: 180px;">
Email
</td>
<td style="width: 130px; max-width:130px;">
Opções
</td>
</tr>
......
Someone once needed something like this?
Solution formulated with the help of Diego Souza
$nome = "{$linha['nome']}";
//conta numero de caracteres da string
$tam = strlen($nome);
//se string tiver mais que 25 caracteres
if($tam > 25){
//Exibe apenas 25 caracteres
$rest = substr($nome, 0, 25);
echo $rest . "...";
}else{
echo $nome;
}
Um, this substr method is interesting, in case I can count the number of characters of my string and if it is larger than x, then I will use the substr method
– Charles Fay
Ysso even! It can be so too.
– Diego Souza
But it will end up not working, because the string size can be big.... or muuuuito grande, then in case my substr is set to -10...it will end up not serving when the string is too large
– Charles Fay
Is there any way I can display only x characters of a string? Regardless of its size show up to 25 characters for example...
– Charles Fay
Using the
substr
even.substr('Essa é uma frase com 36 caracteres !', 0, 25)
.– Diego Souza
That’s it, it worked. Thank you very much!
– Charles Fay