-4
<?php 
include ($_SERVER['DOCUMENT_ROOT'].'/header.php');
include ($_SERVER['DOCUMENT_ROOT'].'/adtop.php');
if(mysql_num_rows($deals) > 0){

    while($row = mysql_fetch_assoc($deals)){
  echo '<div id="dealbox">'; 

echo '<div id="dealdesc class="more">';
echo $row['dealdesc'];
echo '</div>';
}
?>

How do I limit $row['dealdesc'] to show a maximum of 200 characters and display a 'read more' button which, when clicked, will display the full length of $row['dealdesc']?

The Codesee
  • 3,714
  • 5
  • 38
  • 78

1 Answers1

1

You want to use substr function of php. Use it as below.

substr($word, 0, 200)

Now you should create two div. One of them have to have full text, but another less form. By default full form is hidden, after clicking to read more button full text will be shown and less form will be hidden. For example:

<div id="full" style="display:none">full text</div>

<div id="less">less text</div>


$('#less').click(function(){
$('#less').hide();
$('#full').show();
});
Javid Aliyev
  • 436
  • 4
  • 11