Php 如果关键字不匹配,如何显示消息

Php 如果关键字不匹配,如何显示消息,php,mysql,search,Php,Mysql,Search,我正试图显示上传的简历,以管理员的类别,这是在一个下拉列表中,当我选择网页设计师它显示所有上传的网页设计师的简历,但如果关键字不匹配的任何类别,那么它应该会显示一条消息“没有在这个类别找到简历”,这是我想我是新的php请帮助我,如果你可以的话。谢谢 <?php $cat=$_GET['cat']; // Security will be added here. $results = mysql_query("SELECT * FROM resumes where profile lik

我正试图显示上传的简历,以管理员的类别,这是在一个下拉列表中,当我选择网页设计师它显示所有上传的网页设计师的简历,但如果关键字不匹配的任何类别,那么它应该会显示一条消息“没有在这个类别找到简历”,这是我想我是新的php请帮助我,如果你可以的话。谢谢

<?php

$cat=$_GET['cat']; // Security will be added here.

$results = mysql_query("SELECT * FROM resumes where profile like '%$cat%' ORDER BY id desc LIMIT 0, 50000");

while($row = mysql_fetch_array($results)) {

$anymatches = mysql_num_rows($results);

?>

管理面板
函数cmd_del(){
var x=确认(“是否要删除此简历?”);
if(x)
返回true;
其他的
返回false;
}
Rozgaar4all管理面板
已成功删除简历。
管理按类别分类的简历会计、财务、税务、公司秘书、AuditAnalytics&;商业智能金融服务、银行、投资、保险、BPO、KPO、LPO、客户服务、运营HR、招聘、行政管理、IRMarketing、广告、MR、公关、媒体策划制作、制造、维护现场工程、项目管理工程设计、研发;数据销售、零售、业务开发发货IT软件-所有作业软件类别IT软件-应用程序编程、维护软件-客户端/服务器编程IT软件-DBA、数据仓库IT软件-ERP、CRMIT软件-嵌入式、EDA、VLSI、ASIC、芯片设计IT软件-网络管理、,安全IT软件-QA&;测试IT软件-系统编程IT软件-电信软件IT软件-系统、EDP、MISIT软件-电子商务、互联网技术IT软件-MainframeIT软件-MobileIT软件-MiddlewareIT软件-其他更多类别的桌面管理-IT工单管理-非IT架构、室内设计、创意、,用户体验酒店、餐厅新闻、编辑、内容策略、管理咨询、企业规划自营职业者、企业家、独立顾问、运输、进口、销售执行助理、前台、数据中心法律、监管、知识产权供应链、物流、采购、材料医疗、保健、,R&;D、 制药、生物技术包装教学、教育、培训、咨询IT硬件、技术支持、电信工程时装设计、营销电视、电影、制作、广播旅行、旅游、票务、航空安全部队、安全服务政府、国防海外、国际工作跟踪、批发商制药、,生物技术、临床研究和其他
简历总数:()

mysql\u num\u行
不应在while循环中。如果将其移动到循环之后,只要sql查找正确,代码应该可以正常工作

像这样:

while($row = mysql_fetch_array($results)) {
    //output your resumes here
}
if( mysql_num_rows($results)==0 ) echo "<p>No resumes found in this category.</p>";
while($row=mysql\u fetch\u array($results)){
//在这里输出你的简历
}
如果(mysql_num_rows($results)==0)回显“在此类别中未找到任何简历。

”;
希望此代码对您有所帮助

<?php

    $cat=$_GET['cat']; // Security will be added here.

    $results = mysql_query("SELECT * FROM resumes where profile like '%$cat%' ORDER BY id desc LIMIT 0, 50000");

    // Dont place mysql_num_rows inside loop
    // It returns same value only if its inside in loop
    $anymatches = mysql_num_rows($results); 

    //If mysql_num_rows has more than 0 let run in loop
    if($anymatches > 0){

        while($row = mysql_fetch_array($results)) {

            //loop so on

        }       

    }else{ // else number of rows is 0 print your message

        echo '<p>No resumes found in this category.</p>';       

    }    

?>
问题已解决

我在代码的顶部添加了这两行

$results = mysql_query("SELECT * FROM resumes where profile like '%$cat%' ORDER BY id desc LIMIT 0, 50000");
$anymatches = mysql_num_rows($results);

你犯了什么错误?就目前而言,你实际上没有提出任何要求。另外,学习使用mySQLi,而不是不推荐使用的mySQL。还有,omg是一个
font
标记。使用cssUndefined变量:anymatches您的意思是这样的while($row=mysql\u fetch\u array($results))$anymatches=mysql\u num\u rows($results);{再次不工作您想看完整的页面吗?我肯定我在某处犯了一些错误。。。
<?php

    $cat=$_GET['cat']; // Security will be added here.

    $results = mysql_query("SELECT * FROM resumes where profile like '%$cat%' ORDER BY id desc LIMIT 0, 50000");

    // Dont place mysql_num_rows inside loop
    // It returns same value only if its inside in loop
    $anymatches = mysql_num_rows($results); 

    //If mysql_num_rows has more than 0 let run in loop
    if($anymatches > 0){

        while($row = mysql_fetch_array($results)) {

            //loop so on

        }       

    }else{ // else number of rows is 0 print your message

        echo '<p>No resumes found in this category.</p>';       

    }    

?>
$results = mysql_query("SELECT * FROM resumes where profile like '%$cat%' ORDER BY id desc LIMIT 0, 50000");
$anymatches = mysql_num_rows($results);