Check if a row exists using old mysql_* API

前端 未结 6 1482
囚心锁ツ
囚心锁ツ 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:42

    Easiest way to check if a row exists:

    $lectureName = mysql_real_escape_string($lectureName);  // SECURITY!
    $result = mysql_query("SELECT 1 FROM preditors_assigned WHERE lecture_name='$lectureName' LIMIT 1");
    if (mysql_fetch_row($result)) {
        return 'Assigned';
    } else {
        return 'Available';
    }
    

    No need to mess with arrays and field names.

提交回复
热议问题