Mysql
 sql >> Teknologi Basis Data >  >> RDS >> Mysql

Masukkan data jika jumlah baris lebih besar dari 0 tidak berfungsi

function storeLink($url,$gathered_from) {

    global $conn;   
    $querycheck = "SELECT COUNT(*) as CNT FROM test WHERE link = '$url'";
    $resultcheck = mysqli_query($conn, $querycheck);
    $row = mysqli_fetch_array($resultcheck, MYSQLI_ASSOC);

    if($row['CNT'] < 1) {
       echo "<font color='red'>".$row['CNT']."</font>";
       $url = mysqli_real_escape_string($conn,$url);
       $gathered_from = mysqli_real_escape_string($conn,$gathered_from);
       $query = "INSERT INTO test (link, source) VALUES ('$url', '$gathered_from')";
       mysqli_query($conn,$query) or die('Error, insert query failed');
    }
}

ATAU

function storeLink($url,$gathered_from) {

    global $conn;   
    $querycheck = "SELECT link FROM test WHERE link = '$url'";
    $resultcheck = mysqli_query($conn, $querycheck);
    $row = mysqli_fetch_array($resultcheck, MYSQLI_ASSOC);

    if(mysqli_num_rows($resultcheck)==0) {
       echo "<font color='red'>".mysqli_num_rows($resultcheck)."</font>";
       $url = mysqli_real_escape_string($conn,$url);
       $gathered_from = mysqli_real_escape_string($conn,$gathered_from);
       $query = "INSERT INTO test (link, source) VALUES ('$url', '$gathered_from')";
       mysqli_query($conn,$query) or die('Error, insert query failed');
    }
}


  1. Database
  2.   
  3. Mysql
  4.   
  5. Oracle
  6.   
  7. Sqlserver
  8.   
  9. PostgreSQL
  10.   
  11. Access
  12.   
  13. SQLite
  14.   
  15. MariaDB
  1. MySQL - Baris ke Kolom

  2. bantuan dengan kueri melalui tabel relasi

  3. Mengubah nilai dropdown berikutnya dengan acara onchange dropdown sebelumnya

  4. PHP MySQL - Kesalahan:Tidak Ada Basis Data yang dipilih

  5. Dynamic Linq gagal saat menggunakan Berisi melawan Int Field