Witam. Chciałbym zrobić takie coś, że kiedy text ma więcej niż 300txt to, żeby pokazało te 300txt a resztę ukryło z napisem 'pokaż więcej'.
index.php :
<?php
session_start();
?>
<!DOCTYPE html>
<html lang="pl">
<head>
<meta http-equiv="Content-Type" content="text/html" charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body onload="odliczanie();">
<div id="container">
<div id="aktualności">
<div id="aktualności_logo">
<b>Aktualności</b>
</div>
<?php
//if ((isset($_SESSION['zalogowany'])) && ($_SESSION['zalogowany'] ==true))
//{
echo'
<div id="Dodaj_komentarz">
<form action="wyslij.php" method="post" >
<input class="Komentarz" type="text" name="autor" placeholder="Imię i Nazwisko"/></br>
<input class="Komentarz" type="text" name="tytul" placeholder="Tytuł"/></br>
<textarea class="Tresc_aktualnosci" type="text" name="tresc" placeholder="Treść"></textarea></br>
</br><input class="Komentarz" type="file" name="image"/></br>
<input class="Komentarz" type="submit" name="Submit" value="Dodaj"/>
</form>
</div>';
//}
?>
<?php
if(isset($SESSION['e_aktualnosci']))
{
echo'
<div id="Blad_aktualnosci_img">
<img width="50" height="50" src="index_files/Blad_logowania-rejestracji.png">
<div id="Blad_aktualnosci_text">'
.$SESSION['e_aktualnosci'].
'</div>
</div>';
unset($SESSION['e_aktualnosci']);
}
?>
<?php
try
{
require_once("connect1.php");
$polaczenie = new mysqli($host, $db_user, $db_password, $db_name);
if($polaczenie->connect_errno != 0)
{
throw new Exception(mysqli_connect_error());
}
else
{
$sprawdz = $polaczenie->query("SELECT * FROM komentarze ORDER BY `id` DESC");
if($sprawdz->num_rows > 0)
{
$num = $sprawdz->num_rows;
for($i = $num; $i >= 1; $i -= 1)
{
if($komentarz = $polaczenie->query("SELECT * FROM komentarze WHERE id='$i'"))
{
$wiersz = $komentarz->fetch_assoc();
if($wiersz['banned'] == 1)
{
continue;
}
echo '
</br>
<div class="Komentarz">
<div id="Komentarz_tytul">
<b>
</br>'
.$wiersz['tytul'].
'</b>
</div>
<div id="Komentarz_tresc">'
.$wiersz['tresc'].''
'</div>
<div id="Komentarz_autor-data">
'.$wiersz['autor'].'</br>
'.$wiersz['data'].'
</div>';
if ((isset($_SESSION['zalogowany'])) && ($_SESSION['zalogowany'] ==true))
{
echo'
<div id="Komentarz_usun">
<a class="Komentarz_usun" href="usun.php?id='.$i.'">
Usuń
</a>
</div>';
}
'</div>';
}
}
}
$polaczenie->close();
}
}
catch(Example $error)
{
echo "ERROR!";
}
?>
</div>
</div>
</body>
</html>
Wiem, że trzeba zrobić if(strlen($wiersz['tresc'])) ale nie wiem co dalej.