Check if a row exists using old mysql_* API

前端 未结 6 1472
囚心锁ツ
囚心锁ツ 2020-12-01 15:47

I just want to check and see if a row exists where the $lectureName shows. If a row does exist with the $lectureName somewhere in it, I want the function to return "ass

6条回答
  •  春和景丽
    2020-12-01 16:37

    This ought to do the trick: just limit the result to 1 row; if a row comes back the $lectureName is Assigned, otherwise it's Available.

    function checkLectureStatus($lectureName)
    {
        $con = connectvar();
        mysql_select_db("mydatabase", $con);
        $result = mysql_query(
            "SELECT * FROM preditors_assigned WHERE lecture_name='$lectureName' LIMIT 1");
    
        if(mysql_fetch_array($result) !== false)
            return 'Assigned';
        return 'Available';
    }
    

提交回复
热议问题