# show more/less button (expand text) in table cell



## JoeMorgan (Nov 28, 2008)

I have a html table that is populated using php:


```
<table class="flat-table flat-table-1" width="100%">
    
    <tr style="background-color:#FFF;">
        <td class="table-head">Name</td>
        <td class="table-head">Review</td>
        <td class="table-head">Rating</td>
    </tr>

    <?php
    //run a query to find all the fields in the review table that belong to the specific hall, using the id in the url ($current_id)
    if ($r = $db->prepare("SELECT * FROM reviews WHERE hall_id = :current_id")) {
        //bind the parameters used in the above query using the 'current_id' variable
        $r->bindParam(':current_id', $current_id);
        //Execute the prepared query
        $r->execute(); 
 
        //search review table for all fields and save them in $review
        $reviewtemp = $r->fetchAll();
        foreach( $reviewtemp as $review) {
			
        //loop and output the reviews
    ?>

    <tr>
    <td><? echo $review['name'];?></td>
    <td><? echo $review['review']; ?></td>
    <td><? echo $review['overall']; }}?></td>
    </tr>
    </table>
```
The - `<td><? echo $review['review']; ?></td>`' - contains longs pieces of text that need to be shorted using a show more/less button, if the piece of text is over 400 characters.

I have tried using pieces of code I have found on the internet but have had no luck. I am hoping that maybe somebody on here can point me in the right direction? I am happy to use any solution I can.

The following piece of code is the kind of thing I need to use, however I am unsure how to implement it into my code: Edit fiddle - JSFiddle


----------

