簡體   English   中英

在表格單元格中隱藏/顯示更多文本按鈕

[英]Hide/show more text button within table cell

我目前有一個使用PHP腳本填充的html表。 腳本循環遍歷數據庫中的一個表,並將2個字段的值一遍又一遍地輸出到表中的兩個不同的單元格中。這兩個不同的值是對大學禮堂的評論以及離開者的姓名評價。

有些評論可能會很長,因此需要使用“更多/更少”按鈕來縮短。 我不確定如何創建此按鈕並將其顯示在表格的每個單元格中(因此可以擴展每個評論)。

我知道我對此的解釋不是很好,但是如果有人知道實現這一目標的方法,我將不勝感激!

編輯:

抱歉,我應該將代碼放在這里。

以下是表格的HTML代碼和PHP代碼:

<tr>
<td><table class="flat-table flat-table-1" width="100%">
<tr>
</tr>

<tr style="background-color:#FFF;">
<td class="table-head">Name</td>
<td class="table-head">Rating</td>
</tr>

<?php
//run a query to find all the fields in the hall table that belong to the specific     university, using the id in the url ($current_id)
if ($r = $db->prepare("SELECT * FROM reviews WHERE hall_id = :current_id")) { 
  $r->bindParam(':current_id', $current_id);
  $r->execute(); // Execute the prepared query.

//search table for all fields and save them in $hall
$reviewtemp = $r->fetchAll();
foreach( $reviewtemp as $review) {

//loop and output hall names below
?>
<tr>
<td><? echo $review['name'];?></td>
<td><? echo $review['review']; }}?></td>
</tr>
</table>
</td>
</tr>
</table>

更多/更少按鈕需要顯示在此“ td”的底部-

<td><? echo $review['review']; }}?></td>

為什么不只輸出將隱藏/顯示其他內容的JavaScript鏈接?

用javascript顯示更多

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM