以下是我显示用户评论的查询.效果很好:
enter
$query='SELECT
customers.cust_id,
customers.f_name,
customers.l_name,
user_comments.comment_txt,
clubs.name_club
from
customers
inner join
user_comments
on customers.cust_id = user_comments.cust_id
inner join
clubs
on user_comments.cust_id = clubs.cust_id
ORDER BY RAND() LIMIT 1,1
';
$result = mysql_query($query);
while($row = mysql_fetch_array($result)){
$nameclub =$row['name_club'];
$comment =$row['comment_txt'];
echo '<div><img src="images/arrow.gif"> <a href="news.php?id='.$row['cust_id'].'"> Name : '.$nameclub.'</a></div>';
echo '<div>'.$comment.'</div><br>';
echo '<div>'.$row['f_name'].' '.$row['l_name'].'</div>';
}
echo '<p style="text-align: left"><a href="newsarchive.php"> Show all comments</ ></a></p> '; ?>
Run Code Online (Sandbox Code Playgroud)
我现在想要显示用户评论的大约100个字符.所以我相应地更改了我的查询,但它不起作用:
enter $query='SELECT
customers.cust_id,
customers.f_name,
customers.l_name,
user_comments.comment_txt.substr(comment_txt,1,100) as comment_txt,
clubs.name_club
from
customers
inner join
user_comments
on customers.cust_id = …Run Code Online (Sandbox Code Playgroud)