如何获取 mysql 中单词不超过 40 个字符的列?
基本上,我正在尝试在 php 中创建一个函数,该函数将为我提供最新的列(消息),其中单词不超过 40 个字符。我能够获取最新消息,但我不知道如何仅获取单词长度不超过 40 个字符的最新消息。请参考 $callrecent 变量。
<?php
function recentpost($postnum) {
$callrecent = "SELECT message FROM messages WHERE message (HAS NO WORD GREATER THAN 40 CHARACTERS) ORDER BY msg_id DESC LIMIT $postnum,1";
$callrecent_run = mysql_fetch_assoc(mysql_query($callrecent));
$message = stripslashes($callrecent_run['message']);
return $message;
}
?>
Basically, I'm trying to create a function in php that would give me the most recent column (message) that has no word greater than 40 characters. I was able to get the most recent message but I have no idea how to only get the most recent message that has no word greater than 40 characters. Please refer to the $callrecent variable.
<?php
function recentpost($postnum) {
$callrecent = "SELECT message FROM messages WHERE message (HAS NO WORD GREATER THAN 40 CHARACTERS) ORDER BY msg_id DESC LIMIT $postnum,1";
$callrecent_run = mysql_fetch_assoc(mysql_query($callrecent));
$message = stripslashes($callrecent_run['message']);
return $message;
}
?>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你可以使用正则表达式
you could use regular expressions
尝试
Try