Check if a row exists using old mysql_* API

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

    Use mysql_num_rows(), to check if rows are available or not

    $result = mysql_query("SELECT * FROM preditors_assigned WHERE lecture_name='$lectureName' LIMIT 1");
    $num_rows = mysql_num_rows($result);
    
    if ($num_rows > 0) {
      // do something
    }
    else {
      // do something else
    }
    

提交回复
热议问题