我经营一个失物招领宠物网站,在列出失物招领宠物时遇到麻烦。
http://alphapets.co.nz/lost/lost.php
我不知道如何在描述中只显示几个单词,以便所有列表的大小都相同,并且文本不会溢出。
php如下:
// Retrieves data from MySQL
$data2 = mysql_query("SELECT * FROM pets WHERE status LIKE '".
$thisPage."' ORDER BY `pets`.`ID` DESC")
or die(mysql_error()); //Puts it into an array
while($info2 = mysql_fetch_array( $data2 )) {
//Outputs the image and other data
echo "<div id='wrapper4'>
<div id='pet_profile_image'>
<img src=http://alphapets.co.nz/lost/petimages/resized_$info2[date]$info2[photo]
class='mainimage'>
</div>
<div id='pet_description'>
<h2><a href='/download.php?ID=$info2[ID]'>$info2[name]</a> </h2><br />
<b>Location:</b> $info2[town], $info2[city] <br />
<b>Description</b>: $info2[description] <br /><br />
<a href='/download.php?ID=$info2[ID]'>Click here for more</a>
</div>
</div>";
}
最佳答案
这也许会有帮助;
http://www.daniweb.com/web-development/php/threads/131085/how-to-display-part-of-text-from-msql