php mysql 查询后过滤
尝试在查询后过滤结果。需要在tinytext字符串中找到一个字符串。看起来像:会计、ACT、代数 1、代数 2、美国历史、生物学、微积分、经济学、英语、欧洲历史、几何、语法、文学、钢琴、校对、心理学、阅读、SAT 数学、SAT 阅读、 SAT 写作、统计、小提琴、词汇、
Code - 要查找的主题字符串是 $subject
,要搜索的列表是 $row['主题列表']
$result = mysql_query($query, $dbConn);
$i=0;
while ($row = @mysql_fetch_assoc($result)){
$results[$i]['Name'] = $row['Name'];
$results[$i]['Zip'] = $row['ZipCode'];
$results[$i]['SubjectList'] = $row['SubjectList'];
$i++;
}
Trying to filter the results after a query. Need to find a string inside of a tinytext string. That looks like: accounting, ACT, algebra 1, algebra 2, American history, biology, calculus, economics, English, European history, geometry, grammar, literature, piano, proofreading, psychology, reading, SAT math, SAT reading, SAT writing, statistics, violin, vocabulary,
Code - subject string to find is $subject
and the list to search is $row['SubjectList']
$result = mysql_query($query, $dbConn);
$i=0;
while ($row = @mysql_fetch_assoc($result)){
$results[$i]['Name'] = $row['Name'];
$results[$i]['Zip'] = $row['ZipCode'];
$results[$i]['SubjectList'] = $row['SubjectList'];
$i++;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你的做法完全错误。
you are doing it completely the wrong way.
虽然我同意 Shrapnels 上校的回答,但在您的具体情况下,您正在寻找
strpos
函数(如果你确实想在 PHP 中执行此操作)While I agree with Col. Shrapnels answer, in your specific case you are looking for the
strpos
function if you really want to do it in PHP