PHP Method for Determining the Existence of Records in a Database

  • 2021-07-26 07:20:04
  • OfStack

This paper describes the method of PHP to judge whether the records in the database exist or not. Share it for your reference.

The specific implementation code is as follows:


<?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']; 
        } 
?> 

I hope this article is helpful to everyone's PHP programming.


Related articles: