Display only a maximum number of characters

Asked

Viewed 49 times

3

My question, I believe, is quite simple, as I can do to display only a maximum amount of characters to the user, for example, 25 characters + "..."

inserir a descrição da imagem aqui

The idea is to limit the characters of these texts, so that the sizes of the divs are not so different.

  • 1

    I don’t know if I understood the question well... but I think I could handle it on the screen even using for example the Javascript Substring. https://www.w3schools.com/jsref/jsref_substring.asp

1 answer

4


You can use the SUBSTRING to make the query return only the first 25 characters:

SELECT SUBSTRING(col_texto, 1, 25) FROM textos;
  • Thank you very, very much

  • I tried to use in another selection query, but this time it did not run select C.id, C.card_name, C.monster_lrl, C.link_image, C.effect_description, C.card_atk, C.card_def, C.quantity, E.edition_name, E.edition_code, S.card_status_desc, A.kind_attribute, K.kind_name, M.kind_monster_name from card C inner join card_editions E on E.id = C.id_card_edition inner join kind_attributes A on A.id = C.id_kind_attributes inner join kind_card K on K.id = C.id_kind_card inner join kind_monster M on M.id = C.id_kind_monster inner join card_status S on S.id = C.id_card_status order by C.id desc limit 5

  • want to use in C.effect_description

  • 1

    When you get to the column C.effect_description try to do: SUBSTRING(C.effect_description, 1, 25)

  • of the Undefined index error

  • 1

    I got it, I used the substr in the exhibition <?= substr($card['effect_description'], 0, 50) ?>

Show 1 more comment

Browser other questions tagged

You are not signed in. Login or sign up in order to post.