小编unf*_*ven的帖子

为什么我的查询不能用于检索子字符串?

以下是我显示用户评论的查询.效果很好:

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">&nbsp;<a   href="news.php?id='.$row['cust_id'].'">&nbsp;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">&nbsp;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)

html php mysql

-2
推荐指数
1
解决办法
53
查看次数

标签 统计

html ×1

mysql ×1

php ×1