如何用PHP判断数据库中的记录是否存在

来源:互联网 发布:配置apache 编辑:程序博客网 时间:2024/05/21 10:56

以下是代码片段:

<?php$sql="select * from checklist where game_id=$gid and task='$task' and status='$status'";$result=mysql_query($sql);$row = mysql_fetch_array($result, MYSQL_ASSOC);    if (!mysql_num_rows($result))        {            echo "record doesn't exist~~~~~!!!!!!";        }    else        {           // echo mysql_num_rows($result)."\n";            echo $row['game_id'];            echo $row['task'];        }?>