Hướng dẫn check if mysql query executed successfully php - kiểm tra xem truy vấn mysql có được thực thi thành công hay không

Đây là kịch bản:

$(document).ready(function(){
   // Delete
   $('.delete_game_cat').click(function(){
       var el = this;
       var id = this.id;
       var splitid = id.split("_");

       // Delete id
       var deleteid = splitid[1];

       // AJAX Request
       $.ajax({
           url: 'delete_game_cat.php',
           type: 'POST',
           data: { id:deleteid },
           success: function(response){
                if(response===1){
                   // Removing row from HTML Table
                   $(el).closest('tr').css('background','tomato');
                   $(el).closest('tr').fadeOut(600, function(){
                       $(this).remove();
                   });
                }else{
                    alert("This category cannot be deleted!");
                }
           }
       });
   });
});

Và truy vấn SQL:

$id = $_POST['id'];
$query = "DELETE FROM games_category WHERE id =".$id;

if(mysqli_query($conn, $query)){
    echo 1;
}else{
    echo 0;
}

mwwaygoo tại hotmail dot com

10 năm trướcSend a MySQL query

Jon tại WebSandBox Dot Net

Predrag Supurovic ¶(string $query, resource $link_identifier = NULL): mixed

18 năm trước

Allen A Brooker GB Net

Richie (at) Richiebartlett.com

Chris tại Hotmail Dot Com ¶

wjyong tại sh263 dot net

Làm thế nào để bạn kiểm tra xem truy vấn SQL có được thực thi trong PHP không?mysql_connect() is assumed. If no such link is found, it will try to create one as if mysql_connect() had been called with no arguments. If no connection is found or established, an

$(document).ready(function(){
   // Delete
   $('.delete_game_cat').click(function(){
       var el = this;
       var id = this.id;
       var splitid = id.split("_");

       // Delete id
       var deleteid = splitid[1];

       // AJAX Request
       $.ajax({
           url: 'delete_game_cat.php',
           type: 'POST',
           data: { id:deleteid },
           success: function(response){
                if(response===1){
                   // Removing row from HTML Table
                   $(el).closest('tr').css('background','tomato');
                   $(el).closest('tr').fadeOut(600, function(){
                       $(this).remove();
                   });
                }else{
                    alert("This category cannot be deleted!");
                }
           }
       });
   });
});
2 level error is generated.

Kiểm tra xem nếu một truy vấn SQL đã được thực thi câu trả lời mã PHP.

Làm thế nào để bạn kiểm tra xem thực thi có thành công trong PHP không?mysql_query() returns a resource on success, or

$(document).ready(function(){
   // Delete
   $('.delete_game_cat').click(function(){
       var el = this;
       var id = this.id;
       var splitid = id.split("_");

       // Delete id
       var deleteid = splitid[1];

       // AJAX Request
       $.ajax({
           url: 'delete_game_cat.php',
           type: 'POST',
           data: { id:deleteid },
           success: function(response){
                if(response===1){
                   // Removing row from HTML Table
                   $(el).closest('tr').css('background','tomato');
                   $(el).closest('tr').fadeOut(600, function(){
                       $(this).remove();
                   });
                }else{
                    alert("This category cannot be deleted!");
                }
           }
       });
   });
});
3 on error.

// peform một truy vấn ..mysql_query() returns

$(document).ready(function(){
   // Delete
   $('.delete_game_cat').click(function(){
       var el = this;
       var id = this.id;
       var splitid = id.split("_");

       // Delete id
       var deleteid = splitid[1];

       // AJAX Request
       $.ajax({
           url: 'delete_game_cat.php',
           type: 'POST',
           data: { id:deleteid },
           success: function(response){
                if(response===1){
                   // Removing row from HTML Table
                   $(el).closest('tr').css('background','tomato');
                   $(el).closest('tr').fadeOut(600, function(){
                       $(this).remove();
                   });
                }else{
                    alert("This category cannot be deleted!");
                }
           }
       });
   });
});
4 on success or
$(document).ready(function(){
   // Delete
   $('.delete_game_cat').click(function(){
       var el = this;
       var id = this.id;
       var splitid = id.split("_");

       // Delete id
       var deleteid = splitid[1];

       // AJAX Request
       $.ajax({
           url: 'delete_game_cat.php',
           type: 'POST',
           data: { id:deleteid },
           success: function(response){
                if(response===1){
                   // Removing row from HTML Table
                   $(el).closest('tr').css('background','tomato');
                   $(el).closest('tr').fadeOut(600, function(){
                       $(this).remove();
                   });
                }else{
                    alert("This category cannot be deleted!");
                }
           }
       });
   });
});
3
on error.

$ query = "Chọn`*`từ người dùng" ;.mysql_fetch_array(), and other functions for dealing with result tables, to access the returned data.

$ results = mysqli_query ($ databaseConnection, $ query) ;.mysql_num_rows() to find out how many rows were returned for a SELECT statement or mysql_affected_rows() to find out how many rows were affected by a DELETE, INSERT, REPLACE, or UPDATE statement.

if (mysqli_num_rows ($ results) == 0) {. will also fail and return

$(document).ready(function(){
   // Delete
   $('.delete_game_cat').click(function(){
       var el = this;
       var id = this.id;
       var splitid = id.split("_");

       // Delete id
       var deleteid = splitid[1];

       // AJAX Request
       $.ajax({
           url: 'delete_game_cat.php',
           type: 'POST',
           data: { id:deleteid },
           success: function(response){
                if(response===1){
                   // Removing row from HTML Table
                   $(el).closest('tr').css('background','tomato');
                   $(el).closest('tr').fadeOut(600, function(){
                       $(this).remove();
                   });
                }else{
                    alert("This category cannot be deleted!");
                }
           }
       });
   });
});
3 if the user does not have permission to access the table(s) referenced by the query.

// Truy vấn trả về 0 hàng !.

} khác {.

Làm thế nào để bạn kiểm tra xem thực thi có thành công trong PHP không?mysql_query() fails and returns

$(document).ready(function(){
   // Delete
   $('.delete_game_cat').click(function(){
       var el = this;
       var id = this.id;
       var splitid = id.split("_");

       // Delete id
       var deleteid = splitid[1];

       // AJAX Request
       $.ajax({
           url: 'delete_game_cat.php',
           type: 'POST',
           data: { id:deleteid },
           success: function(response){
                if(response===1){
                   // Removing row from HTML Table
                   $(el).closest('tr').css('background','tomato');
                   $(el).closest('tr').fadeOut(600, function(){
                       $(this).remove();
                   });
                }else{
                    alert("This category cannot be deleted!");
                }
           }
       });
   });
});
3.

$(document).ready(function(){
   // Delete
   $('.delete_game_cat').click(function(){
       var el = this;
       var id = this.id;
       var splitid = id.split("_");

       // Delete id
       var deleteid = splitid[1];

       // AJAX Request
       $.ajax({
           url: 'delete_game_cat.php',
           type: 'POST',
           data: { id:deleteid },
           success: function(response){
                if(response===1){
                   // Removing row from HTML Table
                   $(el).closest('tr').css('background','tomato');
                   $(el).closest('tr').fadeOut(600, function(){
                       $(this).remove();
                   });
                }else{
                    alert("This category cannot be deleted!");
                }
           }
       });
   });
});
8

Việc thực thi trả về đúng về thành công và sai về thất bại. Từ tài liệu: trả về đúng về thành công hoặc sai về thất bại. Vì vậy, một cái gì đó giống như nếu ($ sth-> thực thi ($ params)) {echo "thành công!"; } khác {echo "thất bại!"; }?

Làm thế nào để tôi biết nếu mysqli truy vấn thành công?mysql_query() returns a resource.

$(document).ready(function(){
   // Delete
   $('.delete_game_cat').click(function(){
       var el = this;
       var id = this.id;
       var splitid = id.split("_");

       // Delete id
       var deleteid = splitid[1];

       // AJAX Request
       $.ajax({
           url: 'delete_game_cat.php',
           type: 'POST',
           data: { id:deleteid },
           success: function(response){
                if(response===1){
                   // Removing row from HTML Table
                   $(el).closest('tr').css('background','tomato');
                   $(el).closest('tr').fadeOut(600, function(){
                       $(this).remove();
                   });
                }else{
                    alert("This category cannot be deleted!");
                }
           }
       });
   });
});
9

Xem thêm

  • mysql_connect () - Mở kết nối với máy chủ MySQL
  • mysql_error () - Trả về văn bản của thông báo lỗi từ hoạt động MySQL trước đó
  • mysql_real_escape_string () - thoát các ký tự đặc biệt trong một chuỗi để sử dụng trong câu lệnh SQL
  • mysql_result () - Nhận dữ liệu kết quả
  • mysql_fetch_assoc () - lấy hàng kết quả như một mảng kết hợp
  • mysql_unbuffered_query () - Gửi truy vấn SQL đến MySQL mà không cần tìm nạp và đệm các hàng kết quả

Jack Dot Whoami tại Gmail Dot Com ¶

15 năm trước

$id = $_POST['id'];
$query = "DELETE FROM games_category WHERE id =".$id;

if(mysqli_query($conn, $query)){
    echo 1;
}else{
    echo 0;
}
0

$id = $_POST['id'];
$query = "DELETE FROM games_category WHERE id =".$id;

if(mysqli_query($conn, $query)){
    echo 1;
}else{
    echo 0;
}
1

$id = $_POST['id'];
$query = "DELETE FROM games_category WHERE id =".$id;

if(mysqli_query($conn, $query)){
    echo 1;
}else{
    echo 0;
}
2

$id = $_POST['id'];
$query = "DELETE FROM games_category WHERE id =".$id;

if(mysqli_query($conn, $query)){
    echo 1;
}else{
    echo 0;
}
3

$id = $_POST['id'];
$query = "DELETE FROM games_category WHERE id =".$id;

if(mysqli_query($conn, $query)){
    echo 1;
}else{
    echo 0;
}
4

$id = $_POST['id'];
$query = "DELETE FROM games_category WHERE id =".$id;

if(mysqli_query($conn, $query)){
    echo 1;
}else{
    echo 0;
}
5

$id = $_POST['id'];
$query = "DELETE FROM games_category WHERE id =".$id;

if(mysqli_query($conn, $query)){
    echo 1;
}else{
    echo 0;
}
6

$id = $_POST['id'];
$query = "DELETE FROM games_category WHERE id =".$id;

if(mysqli_query($conn, $query)){
    echo 1;
}else{
    echo 0;
}
7

$id = $_POST['id'];
$query = "DELETE FROM games_category WHERE id =".$id;

if(mysqli_query($conn, $query)){
    echo 1;
}else{
    echo 0;
}
8

Halion tại Gmail Dot Com ¶

15 năm trước

$id = $_POST['id'];
$query = "DELETE FROM games_category WHERE id =".$id;

if(mysqli_query($conn, $query)){
    echo 1;
}else{
    echo 0;
}
9

Delete0

Delete1

Delete2

Delete3

Delete4

Delete5

Delete6

Delete7

Delete8

Delete9

echo 1;0

echo 1;1

echo 1;2

echo 1;3

echo 1;4

echo 1;5

echo 1;6

echo 1;7

$id = $_POST['id'];
$query = "DELETE FROM games_category WHERE id =".$id;

if(mysqli_query($conn, $query)){
    echo 1;
}else{
    echo 0;
}
8

Halion tại Gmail Dot Com ¶

Nikhil-php tại Nols Dot Com ¶

echo 1;9

echo 0;0

echo 0;1

echo 0;2

$id = $_POST['id'];
$query = "DELETE FROM games_category WHERE id =".$id;

if(mysqli_query($conn, $query)){
    echo 1;
}else{
    echo 0;
}
8

22 năm trước

Ẩn danh ¶

echo 0;4

echo 0;5

echo 0;6

echo 0;7

16 năm trước

Ông Tim ¶

echo 0;8

echo 0;9

response0

response1

response2

$id = $_POST['id'];
$query = "DELETE FROM games_category WHERE id =".$id;

if(mysqli_query($conn, $query)){
    echo 1;
}else{
    echo 0;
}
8

14 năm trước

Davidc tại Edeca Dot Net

response4

response5

response6

response7

response8

response9

ajax0

ajax1

ajax2

$id = $_POST['id'];
$query = "DELETE FROM games_category WHERE id =".$id;

if(mysqli_query($conn, $query)){
    echo 1;
}else{
    echo 0;
}
8

19 năm trước

ialsoagree ¶

ajax4

ajax5

$id = $_POST['id'];
$query = "DELETE FROM games_category WHERE id =".$id;

if(mysqli_query($conn, $query)){
    echo 1;
}else{
    echo 0;
}
8

13 năm trước

ddlshack [at] gmail.dot.com ¶

ajax7

ajax8

ajax9

$query0

11 năm trước

Ông Tim ¶

$query1

$query2

$query3

$query4

$query5

$query6

$query7

$query8

$id = $_POST['id'];
$query = "DELETE FROM games_category WHERE id =".$id;

if(mysqli_query($conn, $query)){
    echo 1;
}else{
    echo 0;
}
8

14 năm trước

Ẩn danh ¶

$link_identifier0

16 năm trước

Ẩn danh ¶

$link_identifier1

$link_identifier2

$id = $_POST['id'];
$query = "DELETE FROM games_category WHERE id =".$id;

if(mysqli_query($conn, $query)){
    echo 1;
}else{
    echo 0;
}
8

16 năm trước

Ông Tim ¶

$link_identifier4

$link_identifier5

$link_identifier6

$link_identifier7

$link_identifier8

$id = $_POST['id'];
$query = "DELETE FROM games_category WHERE id =".$id;

if(mysqli_query($conn, $query)){
    echo 1;
}else{
    echo 0;
}
8

22 năm trước

Davidc tại Edeca Dot Net

$(document).ready(function(){
   // Delete
   $('.delete_game_cat').click(function(){
       var el = this;
       var id = this.id;
       var splitid = id.split("_");

       // Delete id
       var deleteid = splitid[1];

       // AJAX Request
       $.ajax({
           url: 'delete_game_cat.php',
           type: 'POST',
           data: { id:deleteid },
           success: function(response){
                if(response===1){
                   // Removing row from HTML Table
                   $(el).closest('tr').css('background','tomato');
                   $(el).closest('tr').fadeOut(600, function(){
                       $(this).remove();
                   });
                }else{
                    alert("This category cannot be deleted!");
                }
           }
       });
   });
});
00

19 năm trước

Ông Tim ¶

$(document).ready(function(){
   // Delete
   $('.delete_game_cat').click(function(){
       var el = this;
       var id = this.id;
       var splitid = id.split("_");

       // Delete id
       var deleteid = splitid[1];

       // AJAX Request
       $.ajax({
           url: 'delete_game_cat.php',
           type: 'POST',
           data: { id:deleteid },
           success: function(response){
                if(response===1){
                   // Removing row from HTML Table
                   $(el).closest('tr').css('background','tomato');
                   $(el).closest('tr').fadeOut(600, function(){
                       $(this).remove();
                   });
                }else{
                    alert("This category cannot be deleted!");
                }
           }
       });
   });
});
01

$(document).ready(function(){
   // Delete
   $('.delete_game_cat').click(function(){
       var el = this;
       var id = this.id;
       var splitid = id.split("_");

       // Delete id
       var deleteid = splitid[1];

       // AJAX Request
       $.ajax({
           url: 'delete_game_cat.php',
           type: 'POST',
           data: { id:deleteid },
           success: function(response){
                if(response===1){
                   // Removing row from HTML Table
                   $(el).closest('tr').css('background','tomato');
                   $(el).closest('tr').fadeOut(600, function(){
                       $(this).remove();
                   });
                }else{
                    alert("This category cannot be deleted!");
                }
           }
       });
   });
});
02

$(document).ready(function(){
   // Delete
   $('.delete_game_cat').click(function(){
       var el = this;
       var id = this.id;
       var splitid = id.split("_");

       // Delete id
       var deleteid = splitid[1];

       // AJAX Request
       $.ajax({
           url: 'delete_game_cat.php',
           type: 'POST',
           data: { id:deleteid },
           success: function(response){
                if(response===1){
                   // Removing row from HTML Table
                   $(el).closest('tr').css('background','tomato');
                   $(el).closest('tr').fadeOut(600, function(){
                       $(this).remove();
                   });
                }else{
                    alert("This category cannot be deleted!");
                }
           }
       });
   });
});
03

$(document).ready(function(){
   // Delete
   $('.delete_game_cat').click(function(){
       var el = this;
       var id = this.id;
       var splitid = id.split("_");

       // Delete id
       var deleteid = splitid[1];

       // AJAX Request
       $.ajax({
           url: 'delete_game_cat.php',
           type: 'POST',
           data: { id:deleteid },
           success: function(response){
                if(response===1){
                   // Removing row from HTML Table
                   $(el).closest('tr').css('background','tomato');
                   $(el).closest('tr').fadeOut(600, function(){
                       $(this).remove();
                   });
                }else{
                    alert("This category cannot be deleted!");
                }
           }
       });
   });
});
04

$(document).ready(function(){
   // Delete
   $('.delete_game_cat').click(function(){
       var el = this;
       var id = this.id;
       var splitid = id.split("_");

       // Delete id
       var deleteid = splitid[1];

       // AJAX Request
       $.ajax({
           url: 'delete_game_cat.php',
           type: 'POST',
           data: { id:deleteid },
           success: function(response){
                if(response===1){
                   // Removing row from HTML Table
                   $(el).closest('tr').css('background','tomato');
                   $(el).closest('tr').fadeOut(600, function(){
                       $(this).remove();
                   });
                }else{
                    alert("This category cannot be deleted!");
                }
           }
       });
   });
});
05

$(document).ready(function(){
   // Delete
   $('.delete_game_cat').click(function(){
       var el = this;
       var id = this.id;
       var splitid = id.split("_");

       // Delete id
       var deleteid = splitid[1];

       // AJAX Request
       $.ajax({
           url: 'delete_game_cat.php',
           type: 'POST',
           data: { id:deleteid },
           success: function(response){
                if(response===1){
                   // Removing row from HTML Table
                   $(el).closest('tr').css('background','tomato');
                   $(el).closest('tr').fadeOut(600, function(){
                       $(this).remove();
                   });
                }else{
                    alert("This category cannot be deleted!");
                }
           }
       });
   });
});
06

$(document).ready(function(){
   // Delete
   $('.delete_game_cat').click(function(){
       var el = this;
       var id = this.id;
       var splitid = id.split("_");

       // Delete id
       var deleteid = splitid[1];

       // AJAX Request
       $.ajax({
           url: 'delete_game_cat.php',
           type: 'POST',
           data: { id:deleteid },
           success: function(response){
                if(response===1){
                   // Removing row from HTML Table
                   $(el).closest('tr').css('background','tomato');
                   $(el).closest('tr').fadeOut(600, function(){
                       $(this).remove();
                   });
                }else{
                    alert("This category cannot be deleted!");
                }
           }
       });
   });
});
07

$(document).ready(function(){
   // Delete
   $('.delete_game_cat').click(function(){
       var el = this;
       var id = this.id;
       var splitid = id.split("_");

       // Delete id
       var deleteid = splitid[1];

       // AJAX Request
       $.ajax({
           url: 'delete_game_cat.php',
           type: 'POST',
           data: { id:deleteid },
           success: function(response){
                if(response===1){
                   // Removing row from HTML Table
                   $(el).closest('tr').css('background','tomato');
                   $(el).closest('tr').fadeOut(600, function(){
                       $(this).remove();
                   });
                }else{
                    alert("This category cannot be deleted!");
                }
           }
       });
   });
});
08

$(document).ready(function(){
   // Delete
   $('.delete_game_cat').click(function(){
       var el = this;
       var id = this.id;
       var splitid = id.split("_");

       // Delete id
       var deleteid = splitid[1];

       // AJAX Request
       $.ajax({
           url: 'delete_game_cat.php',
           type: 'POST',
           data: { id:deleteid },
           success: function(response){
                if(response===1){
                   // Removing row from HTML Table
                   $(el).closest('tr').css('background','tomato');
                   $(el).closest('tr').fadeOut(600, function(){
                       $(this).remove();
                   });
                }else{
                    alert("This category cannot be deleted!");
                }
           }
       });
   });
});
09

$id = $_POST['id'];
$query = "DELETE FROM games_category WHERE id =".$id;

if(mysqli_query($conn, $query)){
    echo 1;
}else{
    echo 0;
}
8

14 năm trước

Ẩn danh ¶

$(document).ready(function(){
   // Delete
   $('.delete_game_cat').click(function(){
       var el = this;
       var id = this.id;
       var splitid = id.split("_");

       // Delete id
       var deleteid = splitid[1];

       // AJAX Request
       $.ajax({
           url: 'delete_game_cat.php',
           type: 'POST',
           data: { id:deleteid },
           success: function(response){
                if(response===1){
                   // Removing row from HTML Table
                   $(el).closest('tr').css('background','tomato');
                   $(el).closest('tr').fadeOut(600, function(){
                       $(this).remove();
                   });
                }else{
                    alert("This category cannot be deleted!");
                }
           }
       });
   });
});
11

$(document).ready(function(){
   // Delete
   $('.delete_game_cat').click(function(){
       var el = this;
       var id = this.id;
       var splitid = id.split("_");

       // Delete id
       var deleteid = splitid[1];

       // AJAX Request
       $.ajax({
           url: 'delete_game_cat.php',
           type: 'POST',
           data: { id:deleteid },
           success: function(response){
                if(response===1){
                   // Removing row from HTML Table
                   $(el).closest('tr').css('background','tomato');
                   $(el).closest('tr').fadeOut(600, function(){
                       $(this).remove();
                   });
                }else{
                    alert("This category cannot be deleted!");
                }
           }
       });
   });
});
12

$(document).ready(function(){
   // Delete
   $('.delete_game_cat').click(function(){
       var el = this;
       var id = this.id;
       var splitid = id.split("_");

       // Delete id
       var deleteid = splitid[1];

       // AJAX Request
       $.ajax({
           url: 'delete_game_cat.php',
           type: 'POST',
           data: { id:deleteid },
           success: function(response){
                if(response===1){
                   // Removing row from HTML Table
                   $(el).closest('tr').css('background','tomato');
                   $(el).closest('tr').fadeOut(600, function(){
                       $(this).remove();
                   });
                }else{
                    alert("This category cannot be deleted!");
                }
           }
       });
   });
});
13

$(document).ready(function(){
   // Delete
   $('.delete_game_cat').click(function(){
       var el = this;
       var id = this.id;
       var splitid = id.split("_");

       // Delete id
       var deleteid = splitid[1];

       // AJAX Request
       $.ajax({
           url: 'delete_game_cat.php',
           type: 'POST',
           data: { id:deleteid },
           success: function(response){
                if(response===1){
                   // Removing row from HTML Table
                   $(el).closest('tr').css('background','tomato');
                   $(el).closest('tr').fadeOut(600, function(){
                       $(this).remove();
                   });
                }else{
                    alert("This category cannot be deleted!");
                }
           }
       });
   });
});
14

16 năm trước

Ông Tim ¶

$(document).ready(function(){
   // Delete
   $('.delete_game_cat').click(function(){
       var el = this;
       var id = this.id;
       var splitid = id.split("_");

       // Delete id
       var deleteid = splitid[1];

       // AJAX Request
       $.ajax({
           url: 'delete_game_cat.php',
           type: 'POST',
           data: { id:deleteid },
           success: function(response){
                if(response===1){
                   // Removing row from HTML Table
                   $(el).closest('tr').css('background','tomato');
                   $(el).closest('tr').fadeOut(600, function(){
                       $(this).remove();
                   });
                }else{
                    alert("This category cannot be deleted!");
                }
           }
       });
   });
});
15

$(document).ready(function(){
   // Delete
   $('.delete_game_cat').click(function(){
       var el = this;
       var id = this.id;
       var splitid = id.split("_");

       // Delete id
       var deleteid = splitid[1];

       // AJAX Request
       $.ajax({
           url: 'delete_game_cat.php',
           type: 'POST',
           data: { id:deleteid },
           success: function(response){
                if(response===1){
                   // Removing row from HTML Table
                   $(el).closest('tr').css('background','tomato');
                   $(el).closest('tr').fadeOut(600, function(){
                       $(this).remove();
                   });
                }else{
                    alert("This category cannot be deleted!");
                }
           }
       });
   });
});
16

$id = $_POST['id'];
$query = "DELETE FROM games_category WHERE id =".$id;

if(mysqli_query($conn, $query)){
    echo 1;
}else{
    echo 0;
}
8

14 năm trước

Ông Tim ¶

$(document).ready(function(){
   // Delete
   $('.delete_game_cat').click(function(){
       var el = this;
       var id = this.id;
       var splitid = id.split("_");

       // Delete id
       var deleteid = splitid[1];

       // AJAX Request
       $.ajax({
           url: 'delete_game_cat.php',
           type: 'POST',
           data: { id:deleteid },
           success: function(response){
                if(response===1){
                   // Removing row from HTML Table
                   $(el).closest('tr').css('background','tomato');
                   $(el).closest('tr').fadeOut(600, function(){
                       $(this).remove();
                   });
                }else{
                    alert("This category cannot be deleted!");
                }
           }
       });
   });
});
18

14 năm trước

Davidc tại Edeca Dot Net

$(document).ready(function(){
   // Delete
   $('.delete_game_cat').click(function(){
       var el = this;
       var id = this.id;
       var splitid = id.split("_");

       // Delete id
       var deleteid = splitid[1];

       // AJAX Request
       $.ajax({
           url: 'delete_game_cat.php',
           type: 'POST',
           data: { id:deleteid },
           success: function(response){
                if(response===1){
                   // Removing row from HTML Table
                   $(el).closest('tr').css('background','tomato');
                   $(el).closest('tr').fadeOut(600, function(){
                       $(this).remove();
                   });
                }else{
                    alert("This category cannot be deleted!");
                }
           }
       });
   });
});
19

$(document).ready(function(){
   // Delete
   $('.delete_game_cat').click(function(){
       var el = this;
       var id = this.id;
       var splitid = id.split("_");

       // Delete id
       var deleteid = splitid[1];

       // AJAX Request
       $.ajax({
           url: 'delete_game_cat.php',
           type: 'POST',
           data: { id:deleteid },
           success: function(response){
                if(response===1){
                   // Removing row from HTML Table
                   $(el).closest('tr').css('background','tomato');
                   $(el).closest('tr').fadeOut(600, function(){
                       $(this).remove();
                   });
                }else{
                    alert("This category cannot be deleted!");
                }
           }
       });
   });
});
20

$(document).ready(function(){
   // Delete
   $('.delete_game_cat').click(function(){
       var el = this;
       var id = this.id;
       var splitid = id.split("_");

       // Delete id
       var deleteid = splitid[1];

       // AJAX Request
       $.ajax({
           url: 'delete_game_cat.php',
           type: 'POST',
           data: { id:deleteid },
           success: function(response){
                if(response===1){
                   // Removing row from HTML Table
                   $(el).closest('tr').css('background','tomato');
                   $(el).closest('tr').fadeOut(600, function(){
                       $(this).remove();
                   });
                }else{
                    alert("This category cannot be deleted!");
                }
           }
       });
   });
});
21

$id = $_POST['id'];
$query = "DELETE FROM games_category WHERE id =".$id;

if(mysqli_query($conn, $query)){
    echo 1;
}else{
    echo 0;
}
8

19 năm trước

Ông Tim ¶

$(document).ready(function(){
   // Delete
   $('.delete_game_cat').click(function(){
       var el = this;
       var id = this.id;
       var splitid = id.split("_");

       // Delete id
       var deleteid = splitid[1];

       // AJAX Request
       $.ajax({
           url: 'delete_game_cat.php',
           type: 'POST',
           data: { id:deleteid },
           success: function(response){
                if(response===1){
                   // Removing row from HTML Table
                   $(el).closest('tr').css('background','tomato');
                   $(el).closest('tr').fadeOut(600, function(){
                       $(this).remove();
                   });
                }else{
                    alert("This category cannot be deleted!");
                }
           }
       });
   });
});
23

22 năm trước

ialsoagree ¶

$(document).ready(function(){
   // Delete
   $('.delete_game_cat').click(function(){
       var el = this;
       var id = this.id;
       var splitid = id.split("_");

       // Delete id
       var deleteid = splitid[1];

       // AJAX Request
       $.ajax({
           url: 'delete_game_cat.php',
           type: 'POST',
           data: { id:deleteid },
           success: function(response){
                if(response===1){
                   // Removing row from HTML Table
                   $(el).closest('tr').css('background','tomato');
                   $(el).closest('tr').fadeOut(600, function(){
                       $(this).remove();
                   });
                }else{
                    alert("This category cannot be deleted!");
                }
           }
       });
   });
});
24

13 năm trước

ddlshack [at] gmail.dot.com ¶

$(document).ready(function(){
   // Delete
   $('.delete_game_cat').click(function(){
       var el = this;
       var id = this.id;
       var splitid = id.split("_");

       // Delete id
       var deleteid = splitid[1];

       // AJAX Request
       $.ajax({
           url: 'delete_game_cat.php',
           type: 'POST',
           data: { id:deleteid },
           success: function(response){
                if(response===1){
                   // Removing row from HTML Table
                   $(el).closest('tr').css('background','tomato');
                   $(el).closest('tr').fadeOut(600, function(){
                       $(this).remove();
                   });
                }else{
                    alert("This category cannot be deleted!");
                }
           }
       });
   });
});
25

$(document).ready(function(){
   // Delete
   $('.delete_game_cat').click(function(){
       var el = this;
       var id = this.id;
       var splitid = id.split("_");

       // Delete id
       var deleteid = splitid[1];

       // AJAX Request
       $.ajax({
           url: 'delete_game_cat.php',
           type: 'POST',
           data: { id:deleteid },
           success: function(response){
                if(response===1){
                   // Removing row from HTML Table
                   $(el).closest('tr').css('background','tomato');
                   $(el).closest('tr').fadeOut(600, function(){
                       $(this).remove();
                   });
                }else{
                    alert("This category cannot be deleted!");
                }
           }
       });
   });
});
26

$(document).ready(function(){
   // Delete
   $('.delete_game_cat').click(function(){
       var el = this;
       var id = this.id;
       var splitid = id.split("_");

       // Delete id
       var deleteid = splitid[1];

       // AJAX Request
       $.ajax({
           url: 'delete_game_cat.php',
           type: 'POST',
           data: { id:deleteid },
           success: function(response){
                if(response===1){
                   // Removing row from HTML Table
                   $(el).closest('tr').css('background','tomato');
                   $(el).closest('tr').fadeOut(600, function(){
                       $(this).remove();
                   });
                }else{
                    alert("This category cannot be deleted!");
                }
           }
       });
   });
});
27

$id = $_POST['id'];
$query = "DELETE FROM games_category WHERE id =".$id;

if(mysqli_query($conn, $query)){
    echo 1;
}else{
    echo 0;
}
8

11 năm trước

Davidc tại Edeca Dot Net

$(document).ready(function(){
   // Delete
   $('.delete_game_cat').click(function(){
       var el = this;
       var id = this.id;
       var splitid = id.split("_");

       // Delete id
       var deleteid = splitid[1];

       // AJAX Request
       $.ajax({
           url: 'delete_game_cat.php',
           type: 'POST',
           data: { id:deleteid },
           success: function(response){
                if(response===1){
                   // Removing row from HTML Table
                   $(el).closest('tr').css('background','tomato');
                   $(el).closest('tr').fadeOut(600, function(){
                       $(this).remove();
                   });
                }else{
                    alert("This category cannot be deleted!");
                }
           }
       });
   });
});
29

$(document).ready(function(){
   // Delete
   $('.delete_game_cat').click(function(){
       var el = this;
       var id = this.id;
       var splitid = id.split("_");

       // Delete id
       var deleteid = splitid[1];

       // AJAX Request
       $.ajax({
           url: 'delete_game_cat.php',
           type: 'POST',
           data: { id:deleteid },
           success: function(response){
                if(response===1){
                   // Removing row from HTML Table
                   $(el).closest('tr').css('background','tomato');
                   $(el).closest('tr').fadeOut(600, function(){
                       $(this).remove();
                   });
                }else{
                    alert("This category cannot be deleted!");
                }
           }
       });
   });
});
30

$(document).ready(function(){
   // Delete
   $('.delete_game_cat').click(function(){
       var el = this;
       var id = this.id;
       var splitid = id.split("_");

       // Delete id
       var deleteid = splitid[1];

       // AJAX Request
       $.ajax({
           url: 'delete_game_cat.php',
           type: 'POST',
           data: { id:deleteid },
           success: function(response){
                if(response===1){
                   // Removing row from HTML Table
                   $(el).closest('tr').css('background','tomato');
                   $(el).closest('tr').fadeOut(600, function(){
                       $(this).remove();
                   });
                }else{
                    alert("This category cannot be deleted!");
                }
           }
       });
   });
});
31

$(document).ready(function(){
   // Delete
   $('.delete_game_cat').click(function(){
       var el = this;
       var id = this.id;
       var splitid = id.split("_");

       // Delete id
       var deleteid = splitid[1];

       // AJAX Request
       $.ajax({
           url: 'delete_game_cat.php',
           type: 'POST',
           data: { id:deleteid },
           success: function(response){
                if(response===1){
                   // Removing row from HTML Table
                   $(el).closest('tr').css('background','tomato');
                   $(el).closest('tr').fadeOut(600, function(){
                       $(this).remove();
                   });
                }else{
                    alert("This category cannot be deleted!");
                }
           }
       });
   });
});
32

$(document).ready(function(){
   // Delete
   $('.delete_game_cat').click(function(){
       var el = this;
       var id = this.id;
       var splitid = id.split("_");

       // Delete id
       var deleteid = splitid[1];

       // AJAX Request
       $.ajax({
           url: 'delete_game_cat.php',
           type: 'POST',
           data: { id:deleteid },
           success: function(response){
                if(response===1){
                   // Removing row from HTML Table
                   $(el).closest('tr').css('background','tomato');
                   $(el).closest('tr').fadeOut(600, function(){
                       $(this).remove();
                   });
                }else{
                    alert("This category cannot be deleted!");
                }
           }
       });
   });
});
33

$id = $_POST['id'];
$query = "DELETE FROM games_category WHERE id =".$id;

if(mysqli_query($conn, $query)){
    echo 1;
}else{
    echo 0;
}
8

19 năm trước

ialsoagree ¶

$(document).ready(function(){
   // Delete
   $('.delete_game_cat').click(function(){
       var el = this;
       var id = this.id;
       var splitid = id.split("_");

       // Delete id
       var deleteid = splitid[1];

       // AJAX Request
       $.ajax({
           url: 'delete_game_cat.php',
           type: 'POST',
           data: { id:deleteid },
           success: function(response){
                if(response===1){
                   // Removing row from HTML Table
                   $(el).closest('tr').css('background','tomato');
                   $(el).closest('tr').fadeOut(600, function(){
                       $(this).remove();
                   });
                }else{
                    alert("This category cannot be deleted!");
                }
           }
       });
   });
});
35

$(document).ready(function(){
   // Delete
   $('.delete_game_cat').click(function(){
       var el = this;
       var id = this.id;
       var splitid = id.split("_");

       // Delete id
       var deleteid = splitid[1];

       // AJAX Request
       $.ajax({
           url: 'delete_game_cat.php',
           type: 'POST',
           data: { id:deleteid },
           success: function(response){
                if(response===1){
                   // Removing row from HTML Table
                   $(el).closest('tr').css('background','tomato');
                   $(el).closest('tr').fadeOut(600, function(){
                       $(this).remove();
                   });
                }else{
                    alert("This category cannot be deleted!");
                }
           }
       });
   });
});
36

$(document).ready(function(){
   // Delete
   $('.delete_game_cat').click(function(){
       var el = this;
       var id = this.id;
       var splitid = id.split("_");

       // Delete id
       var deleteid = splitid[1];

       // AJAX Request
       $.ajax({
           url: 'delete_game_cat.php',
           type: 'POST',
           data: { id:deleteid },
           success: function(response){
                if(response===1){
                   // Removing row from HTML Table
                   $(el).closest('tr').css('background','tomato');
                   $(el).closest('tr').fadeOut(600, function(){
                       $(this).remove();
                   });
                }else{
                    alert("This category cannot be deleted!");
                }
           }
       });
   });
});
37

$(document).ready(function(){
   // Delete
   $('.delete_game_cat').click(function(){
       var el = this;
       var id = this.id;
       var splitid = id.split("_");

       // Delete id
       var deleteid = splitid[1];

       // AJAX Request
       $.ajax({
           url: 'delete_game_cat.php',
           type: 'POST',
           data: { id:deleteid },
           success: function(response){
                if(response===1){
                   // Removing row from HTML Table
                   $(el).closest('tr').css('background','tomato');
                   $(el).closest('tr').fadeOut(600, function(){
                       $(this).remove();
                   });
                }else{
                    alert("This category cannot be deleted!");
                }
           }
       });
   });
});
38

13 năm trước

Davidc tại Edeca Dot Net

$(document).ready(function(){
   // Delete
   $('.delete_game_cat').click(function(){
       var el = this;
       var id = this.id;
       var splitid = id.split("_");

       // Delete id
       var deleteid = splitid[1];

       // AJAX Request
       $.ajax({
           url: 'delete_game_cat.php',
           type: 'POST',
           data: { id:deleteid },
           success: function(response){
                if(response===1){
                   // Removing row from HTML Table
                   $(el).closest('tr').css('background','tomato');
                   $(el).closest('tr').fadeOut(600, function(){
                       $(this).remove();
                   });
                }else{
                    alert("This category cannot be deleted!");
                }
           }
       });
   });
});
39

19 năm trước

Ông Tim ¶

$(document).ready(function(){
   // Delete
   $('.delete_game_cat').click(function(){
       var el = this;
       var id = this.id;
       var splitid = id.split("_");

       // Delete id
       var deleteid = splitid[1];

       // AJAX Request
       $.ajax({
           url: 'delete_game_cat.php',
           type: 'POST',
           data: { id:deleteid },
           success: function(response){
                if(response===1){
                   // Removing row from HTML Table
                   $(el).closest('tr').css('background','tomato');
                   $(el).closest('tr').fadeOut(600, function(){
                       $(this).remove();
                   });
                }else{
                    alert("This category cannot be deleted!");
                }
           }
       });
   });
});
40

Làm thế nào để bạn kiểm tra xem truy vấn SQL có được thực thi trong PHP không?

Kiểm tra xem nếu một truy vấn SQL đã được thực thi câu trả lời mã PHP..
19 năm trước
// peform một truy vấn ..
$ query = "Chọn`*`từ người dùng" ;.
$ results = mysqli_query ($ databaseConnection, $ query) ;.
if (mysqli_num_rows ($ results) == 0) {.
// Truy vấn trả về 0 hàng !.
} khác {.

Làm thế nào để bạn kiểm tra xem thực thi có thành công trong PHP không?

Việc thực thi trả về đúng về thành công và sai về thất bại. Từ tài liệu: trả về đúng về thành công hoặc sai về thất bại. Vì vậy, một cái gì đó giống như nếu ($ sth-> thực thi ($ params)) {echo "thành công!"; } khác {echo "thất bại!"; }?if($STH->execute($params)) { echo "Success!"; } else { echo "Failure!"; } ?

Làm thế nào để tôi biết nếu mysqli truy vấn thành công?

Trả về các giá trị ¶ Đối với các truy vấn thành công tạo ra một tập kết quả, chẳng hạn như chọn, hiển thị, mô tả hoặc giải thích, mysqli_query () sẽ trả về đối tượng mysqli_result.Đối với các truy vấn thành công khác, mysqli_query () sẽ trả về đúng.mysqli_query() will return a mysqli_result object. For other successful queries, mysqli_query() will return true .

Làm thế nào kiểm tra truy vấn PDO thành công trong PHP?

Làm thế nào kiểm tra truy vấn PDO thành công trong PHP?Để xác định xem phương thức PDO :: EXEC không thành công (trả về Sai hay 0), hãy sử dụng toán tử === để kiểm tra nghiêm ngặt giá trị trả về so với SAI.use the === operator to strictly test the returned value against FALSE.

Giả sử tôi có một bảng danh mục và sau đó tôi có bảng sản phẩm.categories table and then I have products table.

Mỗi sản phẩm thuộc về một số loại.

Bây giờ, tôi muốn xóa một danh mục được gán cho một số sản phẩm.

Điều này sẽ gây ra lỗi, vì tôi không thể xóa một cái gì đó khỏi cơ sở dữ liệu vì quan hệ cơ sở dữ liệu. Mã của tôi bên dưới sẽ loại bỏ một hàng khỏi bảng (sử dụng jQuery) nhưng nó sẽ loại bỏ danh mục thực sự chỉ khi không có sản phẩm nào sử dụng nó.

Tôi đang cố gắng tạo một số cảnh báo lỗi khi tôi nhấp vào biểu tượng Delete và không thể xóa danh mục. Làm thế nào tôi có thể làm điều đó? Tôi muốn một số cửa sổ bật lên jQuery với cảnh báo, nhưng tôi không thực sự biết tôi nên kiểm tra lỗi ở nơi đầu tiên như thế nào.

EDIT: Tôi đã cố gắng sử dụng echo 1;echo 0;response cho ajax nhưng tôi nhận được thông báo cảnh báo mỗi khi tôi muốn xóa một cái gì đó, ngay cả khi không có lỗi. I have tried to use echo 1; and echo 0; as response for ajax but I am getting the warning message every time I want to remove something, even if there is no error.

Hướng dẫn check if mysql query executed successfully php - kiểm tra xem truy vấn mysql có được thực thi thành công hay không