I have a list off latest comments but some text are to long & i would like to show only the first 10 caracts from '. $row['cbody']. ' , so i don`t see the whole comment but just the first 10 letters into '. $row['cbody']. '
How can this be created ???
Code: Select all
<b>Latest Comments</b>
<?php
// connect to the "tests" database
$conn = new mysqli('127.0.0.1', '', '', '');
// check connection
if (mysqli_connect_errno()) {
exit('Connect failed: '. mysqli_connect_error());
}
// SELECT sql query
$sql = "SELECT `ctime`, `citem`, `cuser`, `cbody` FROM `nucleus_comment` ORDER BY `nucleus_comment`.`ctime` DESC";
// perform the query and store the result
$result = $conn->query($sql);
// if the $result contains at least one row
if ($result->num_rows > 0) {
// output data of each row from $result
while($row = $result->fetch_assoc()) {
echo ' <br /><br /> <a href="http://145.53.93.209/News/index.php?itemid='. $row['citem']. '#c" title="Show Comment" class="postlink" target="home">'. $row['ctime']. '</a> '. $row['cbody']. ' '. $row['cuser'];
}
}
else {
echo '0 results';
}
$conn->close();
?>