اذهب إلى المحتوى
  • 0

اظهار رسالة عند الضغط على زر الحذف

ايمن ميلاد

السؤال

السلام عليكم لدي صفحة تالية به جدول يتم عرض بيانات اريد عندما اضغط علي زر حذف تظهر رسالة هل انت متاكد من عملية الحذف اذا ضغطت نعم يحذف اذا ضغط لا يرجع للنفس صفحة 

!DOCTYPE html>
<html lang="ar" dir="rtl">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>الرئيسية</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet"
    integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
    <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>

</head>
<body>
    <div class="container">
<table class="table my-5  table-bordered table-striped">
  <thead>
  <button class="btn btn-success mt-3"><a href="index.php" class="text-decoration-none text-light" >اضافة بيانات </a>  </button>

    <tr>
      <th class="text-center  table-primary" scope="col">#</th>
      <th class="text-center table-primary" scope="col">  الاسم</th>
      <th class="text-center table-primary"  scope="col">البريد الالكتروني </th>
      <th class="text-center table-primary" scope="col"> رقم الهاتف </th>
      <th class="text-center table-primary" scope="col"> العمليات  </th>


       
    </tr>
  </thead>
  <tbody>
    <?php 
   include 'dbcon.php';
   

   
  $sql="select *from users";
  $resault=mysqli_query($conn,$sql);
   
    $resault=mysqli_query($conn,$sql);
    while($row=mysqli_fetch_array($resault))
    {
      $id=$row['id'];
     

      
        echo '<tr > 
              <td class="text-center  "> '.$row['id'].' </td>
              <td class="text-center "> '.$row['name'].' </td>
             <td class="text-center ">  '.$row['email'].' </td> 
             <td class="text-center ">  '.$row['phone'].' </td>
             

            <td  class="text-center"> <button class="btn btn-primary  my-3"> <a href="update.php?updateid='.$id.'" class="text-light text-decoration-none"> تعديل</a> </button> 
            <button class="btn btn-danger confirm"  id="delete-row"> <a href="delete.php?deleteid='.$id.'" class="text-light text-decoration-none">حدف </a> </button> 
            <button class="btn btn-success" id="download" onclick="printPage(10)">طباعة</button>            
            </td>
          

             </tr>';

    }
    ?>
  </tbody>
  
</table>
    </div>
    
     
   
</body>
</html>

 

لقطة شاشة 2024-02-22 105602.png

رابط هذا التعليق
شارك على الشبكات الإجتماعية

Recommended Posts

  • 0

عليك إضافة الكود اللازم لعرض رسالة تأكيد قبل حذف السجل عند الضغط على زر "حذف" في الجدول، وذلك من خلال  مكتبة SweetAlert2 لإظهار الرسالة، كالتالي:

<button class="btn btn-danger confirm" id="delete-row"> <a href="delete.php?deleteid='.$id.'" class="text-light text-decoration-none">حذف </a> </button>

وكما ترى، أضفت الفئة "confirm" إلى الزر، وهذا ما نعتمد عليه في الجافا سكريبت لاستهداف الأزرار التي تحتاج إلى تأكيد.

الكود بعد التعديل

<!DOCTYPE html>
<html lang="ar" dir="rtl">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>الرئيسية</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet"
    integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
    <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
</head>
<body>
    <div class="container">
        <table class="table my-5  table-bordered table-striped">
            <thead>
                <button class="btn btn-success mt-3"><a href="index.php" class="text-decoration-none text-light">اضافة بيانات</a></button>
                <tr>
                    <th class="text-center  table-primary" scope="col">#</th>
                    <th class="text-center table-primary" scope="col">الاسم</th>
                    <th class="text-center table-primary" scope="col">البريد الالكتروني</th>
                    <th class="text-center table-primary" scope="col">رقم الهاتف</th>
                    <th class="text-center table-primary" scope="col">العمليات</th>
                </tr>
            </thead>
            <tbody>
                <?php
                include 'dbcon.php';
                $sql = "select *from users";
                $resault = mysqli_query($conn, $sql);
                while ($row = mysqli_fetch_array($resault)) {
                    $id = $row['id'];
                    echo '<tr> 
                        <td class="text-center"> ' . $row['id'] . ' </td>
                        <td class="text-center"> ' . $row['name'] . ' </td>
                        <td class="text-center"> ' . $row['email'] . ' </td> 
                        <td class="text-center"> ' . $row['phone'] . ' </td>
                        <td class="text-center"> 
                            <button class="btn btn-primary my-3"> <a href="update.php?updateid=' . $id . '" class="text-light text-decoration-none"> تعديل</a> </button> 
                            <button class="btn btn-danger confirm" data-id="' . $id . '">حذف</button> 
                            <button class="btn btn-success" onclick="printPage(10)">طباعة</button>            
                        </td>
                    </tr>';
                }
                ?>
            </tbody>
        </table>
    </div>
    <script >
        document.addEventListener('DOMContentLoaded', function() {
    const deleteButtons = document.querySelectorAll('.confirm');
    
    deleteButtons.forEach(button => {
        button.addEventListener('click', function(e) {
            e.preventDefault();
            const id = this.getAttribute('data-id');
            Swal.fire({
                title: 'هل أنت متأكد؟',
                text: "لن تتمكن من التراجع عن هذا الإجراء!",
                icon: 'warning',
                showCancelButton: true,
                confirmButtonColor: '#3085d6',
                cancelButtonColor: '#d33',
                confirmButtonText: 'نعم، احذفه!'
            }).then((result) => {
                if (result.isConfirmed) {
                    window.location.href = 'delete.php?deleteid=' + id;
                }
            });
        });
    });
});
    </script>
</body>
</html>

 

رابط هذا التعليق
شارك على الشبكات الإجتماعية

  • 0
بتاريخ 26 دقائق مضت قال gamal_king:

السلام عليكم لدي صفحة تالية به جدول يتم عرض بيانات اريد عندما اضغط علي زر حذف تظهر رسالة هل انت متاكد من عملية الحذف اذا ضغطت نعم يحذف اذا ضغط لا يرجع للنفس صفحة 

وعليكم السلام ورحمة الله وبركاته .

اولا من الافضل الا يتم الحذف عن طريق الذهاب الى عنوان الحذف بل الافضل ان يتم ارساله عن طريق form .

ثانيا انت قمت باستيراد مكتبة sweetalert بنجاح ولكنك لم تستعملها فى الكود لديك .

اولا يجب اضافة eventlisnter على العنصر الخاص بالذهاب الى عنوان الحذف ويجب اضافه class اليه . ثم عند الضغط عليه نستخدم الكود الخاص ب sweet alert . 

<button class="btn btn-danger confirm"  id="delete-row"> <a href="delete.php?deleteid='.$id.'" class="text-light text-decoration-none delete">حدف </a> </button> 

هنا قمنا باضفة class الى العنصر a يسمى delete .

 <script>
        let s = document.querySelectorAll('.delete');
        for (i = 0; i < s.length; ++i) {
            s[i].addEventListener('click', (e) => {
                e.preventDefault();
                Swal.fire({
                    title: "Do you want to save the changes?",
                    showDenyButton: true,
                    confirmButtonText: "حذف",
                    denyButtonText: "الغاء"
                }).then((result) => {
                    if (result.isConfirmed) {
                        window.location = e.target.href;
                    } else if (result.isDenied) {
                        Swal.fire("لم يتم الحذف", "", "info");
                    }
                });
                
            });
        }
</script>

هنا قمنا باحضار جميع العناصر التى تحتوى على ال class الخاص delete ونقوم بالتكرار عليها واستماع الحدث click وانشاء عنصر ال sweet alert الذى يحتوى على زرارين فقط ويمكنك تغير النص الخاص بالزر كما تريد . وعند الضغط على حذف سيتم الحذف واذا تم الغاء ستظهر لك رساله بانه لم يتم الحذف وستبقى فى نفس الصفحة .

وهذا هو الكود كاملا 

!DOCTYPE html>
<html lang="ar" dir="rtl">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>الرئيسية</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet"
    integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
    <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>

</head>
<body>
    <div class="container">
<table class="table my-5  table-bordered table-striped">
  <thead>
  <button class="btn btn-success mt-3"><a href="index.php" class="text-decoration-none text-light" >اضافة بيانات </a>  </button>

    <tr>
      <th class="text-center  table-primary" scope="col">#</th>
      <th class="text-center table-primary" scope="col">  الاسم</th>
      <th class="text-center table-primary"  scope="col">البريد الالكتروني </th>
      <th class="text-center table-primary" scope="col"> رقم الهاتف </th>
      <th class="text-center table-primary" scope="col"> العمليات  </th>


       
    </tr>
  </thead>
  <tbody>
    <?php 
   include 'dbcon.php';
   

   
  $sql="select *from users";
  $resault=mysqli_query($conn,$sql);
   
    $resault=mysqli_query($conn,$sql);
    while($row=mysqli_fetch_array($resault))
    {
      $id=$row['id'];
     

      
        echo '<tr > 
              <td class="text-center  "> '.$row['id'].' </td>
              <td class="text-center "> '.$row['name'].' </td>
             <td class="text-center ">  '.$row['email'].' </td> 
             <td class="text-center ">  '.$row['phone'].' </td>
             

            <td  class="text-center"> <button class="btn btn-primary  my-3"> <a href="update.php?updateid='.$id.'" class="text-light text-decoration-none"> تعديل</a> </button> 
            <button class="btn btn-danger confirm"  id="delete-row"> <a href="delete.php?deleteid='.$id.'" class="text-light text-decoration-none delete">حدف </a> </button> 
            <button class="btn btn-success" id="download" onclick="printPage(10)">طباعة</button>            
            </td>
          

             </tr>';

    }
    ?>
  </tbody>
  
</table>
    </div>
    
     
    <script>
        let s = document.querySelectorAll('.delete');
        for (i = 0; i < s.length; ++i) {
            s[i].addEventListener('click', (e) => {
                e.preventDefault();
                Swal.fire({
                    title: "Do you want to save the changes?",
                    showDenyButton: true,
                    confirmButtonText: "حذف",
                    denyButtonText: "الغاء"
                }).then((result) => {
                    if (result.isConfirmed) {
                        window.location = e.target.href;
                    } else if (result.isDenied) {
                        Swal.fire("لم يتم الحذف", "", "info");
                    }
                });
                
            });
        }
</script>
</body>
</html>

 

رابط هذا التعليق
شارك على الشبكات الإجتماعية

  • 0

لماذا لايتم الحذف عملت نفس كود الذي كتبته وهذا كود صفحة delete 

<?php
include 'dbcon.php';

$id = $_GET['deleteid'];

// تحقق من وجود قيمة للمتغير $id
if (isset($id) && !empty($id)) {
    $id = $_GET['deleteid'];

    $sql = "DELETE FROM `users` WHERE id=$id";
    $result = mysqli_query($conn, $sql);
}


?>
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
</head>

<body>

</body>

</html>

 

رابط هذا التعليق
شارك على الشبكات الإجتماعية

  • 0

لعمل ذلك يجب استخدام هذا الكود:

<button class="btn btn-danger confirm" id="delete-row"> <a href="delete.php?deleteid='.$id.'" class="text-light text-decoration-none">حذف </a> </button>
 

بحيث يستخدم الكود مع مكتبة SweetAlert2.

في الزر "حذف"، نقوم بإضافة الكلاس "confirm" لتفعيل السيناريو الذي يتطلب تأكيدًا قبل الحذف، ويُمكنك استخدام الرابط المحدد في الزر لتوجيه المستخدم إلى الصفحة "delete.php" للقيام بعملية الحذف بعد التأكيد.

هناك طريقتين للقيام بذلك، أولهما باستخدام عنصر زر مباشرة بهذا الشكل:

<button class="btn btn-danger confirm" id="delete-row" onclick="confirmDelete('delete.php?deleteid=<?php echo $id; ?>')">حذف</button>

الثانية باستخدام تابع:

<a href="#" class="btn btn-danger confirm" id="delete-row" data-id="<?php echo $id; ?>">حذف</a>

ثم يمكن استخدام السكريبت التالي للتعامل مع الأحداث وعرض رسالة التأكيد:

<script>
    document.addEventListener('DOMContentLoaded', function() {
        const deleteButtons = document.querySelectorAll('.confirm');

        deleteButtons.forEach(button => {
            button.addEventListener('click', function(e) {
                e.preventDefault();
                const id = this.getAttribute('data-id');
                Swal.fire({
                    title: 'هل أنت متأكد؟',
                    text: "لن تتمكن من التراجع عن هذا الإجراء!",
                    icon: 'warning',
                    showCancelButton: true,
                    confirmButtonColor: '#3085d6',
                    cancelButtonColor: '#d33',
                    confirmButtonText: 'نعم، احذفه!'
                }).then((result) => {
                    if (result.isConfirmed) {
                        window.location.href = 'delete.php?deleteid=' + id;
                    }
                });
            });
        });
    });
</script>

فهذا السكريبت يضيف مستمعين للأحداث إلى جميع الأزرار التي تحتوي على الكلاس "confirm". وعند النقر على أي من هذه الأزرار، يتم عرض رسالة تأكيد من خلال مكتبة SweetAlert2، وفي حالة الموافقة، يتم توجيه المستخدم إلى صفحة "delete.php" مع معرف السجل المراد حذفه.

رابط هذا التعليق
شارك على الشبكات الإجتماعية

  • 0
بتاريخ 5 دقائق مضت قال gamal_king:

لماذا لايتم الحذف عملت نفس كود الذي كتبته وهذا كود صفحة delete 

<?php
include 'dbcon.php';

$id = $_GET['deleteid'];

// تحقق من وجود قيمة للمتغير $id
if (isset($id) && !empty($id)) {
    $id = $_GET['deleteid'];

    $sql = "DELETE FROM `users` WHERE id=$id";
    $result = mysqli_query($conn, $sql);
}


?>
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
</head>

<body>

</body>

</html>
 

 

هل عند الضغط على حذف يذهب الى صفحة delete.php ؟ هل يمكنك ارسال الرابط الذى يقوم بالذهاب اليه وصورة الصفحة عند تحميلها .

لان الكود من المفترض ان يحذف جيدا من الممكن ان تكون هناك مشكلة فى الاتصال بقاعدة البيانات

رابط هذا التعليق
شارك على الشبكات الإجتماعية

  • 0
بتاريخ 1 دقيقة مضت قال gamal_king:

اثناء الضغط علي الزر وبعد يذهب للرابط مرفق

1.png

2.png

نعم بالفعل الخطا فى ال deleteid هو الان ب null .

هناك خطأ عند اعادة التوجيه .

يمكنك تجربة الكود الذى ارفقته لك و اخبارى بالنتيجه

رابط هذا التعليق
شارك على الشبكات الإجتماعية

  • 0
بتاريخ 2 دقائق مضت قال gamal_king:

اثناء الضغط علي الزر وبعد يذهب للرابط مرفق

1.png

2.png

<!DOCTYPE html>
<html lang="ar" dir="rtl">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>الرئيسية</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet"
    integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
    <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>

</head>
<body>
    <div class="container">
<table class="table my-5  table-bordered table-striped">
  <thead>
  <button class="btn btn-success mt-3"><a href="index.php" class="text-decoration-none text-light" >اضافة بيانات </a>  </button>

    <tr>
      <th class="text-center  table-primary" scope="col">#</th>
      <th class="text-center table-primary" scope="col">  الاسم</th>
      <th class="text-center table-primary"  scope="col">البريد الالكتروني </th>
      <th class="text-center table-primary" scope="col"> رقم الهاتف </th>
      <th class="text-center table-primary" scope="col"> العمليات  </th>


       
    </tr>
  </thead>
  <tbody>
    <?php 
   include 'dbcon.php';
   

   
  $sql="select *from users";
  $resault=mysqli_query($conn,$sql);
   
    $resault=mysqli_query($conn,$sql);
    while($row=mysqli_fetch_array($resault))
    {
      $id=$row['id'];
     

      
        echo '<tr > 
              <td class="text-center  "> '.$row['id'].' </td>
              <td class="text-center "> '.$row['name'].' </td>
             <td class="text-center ">  '.$row['email'].' </td> 
             <td class="text-center ">  '.$row['phone'].' </td>
             

            <td  class="text-center"> <button class="btn btn-primary  my-3"> <a href="update.php?updateid='.$id.'" class="text-light text-decoration-none"> تعديل</a> </button> 
            <button class="btn btn-danger confirm"  id="delete-row"> <a href="delete.php?deleteid='.$id.'" class="text-light text-decoration-none">حدف </a> </button> 
            <button class="btn btn-success" id="download" onclick="printPage(10)">طباعة</button>            
            </td>
          

             </tr>';

    }
    ?>
  </tbody>
  
</table>
    </div>
    <script>
    document.addEventListener('DOMContentLoaded', function() {
    const deleteButtons = document.querySelectorAll('.confirm');
    
    deleteButtons.forEach(button => {
        button.addEventListener('click', function(e) {
            e.preventDefault();
            const id = this.getAttribute('data-id');
            Swal.fire({
                title: 'هل أنت متأكد؟',
                text: "لن تتمكن من التراجع عن هذا الإجراء!",
                icon: 'warning',
                showCancelButton: true,
                confirmButtonColor: '#3085d6',
                cancelButtonColor: '#d33',
                confirmButtonText: 'نعم، احذفه!'
            }).then((result) => {
                if (result.isConfirmed) {
                    window.location.href = 'delete.php?deleteid=' + id;
                }
            });
        });
    });
});
    </script>
    
     
   
</body>
</html>
<?php
include 'dbcon.php';

$id = $_GET['deleteid'];

// تحقق من وجود قيمة للمتغير $id
if (isset($id) && !empty($id)) {
    $id = $_GET['deleteid'];

    $sql = "DELETE FROM `users` WHERE id=$id";
    $result = mysqli_query($conn, $sql);
}

 

رابط هذا التعليق
شارك على الشبكات الإجتماعية

  • 0

قم باستخدام هذا الكود واخبرنى بالنتيجة

!DOCTYPE html>
<html lang="ar" dir="rtl">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>الرئيسية</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet"
    integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
    <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>

</head>
<body>
    <div class="container">
<table class="table my-5  table-bordered table-striped">
  <thead>
  <button class="btn btn-success mt-3"><a href="index.php" class="text-decoration-none text-light" >اضافة بيانات </a>  </button>

    <tr>
      <th class="text-center  table-primary" scope="col">#</th>
      <th class="text-center table-primary" scope="col">  الاسم</th>
      <th class="text-center table-primary"  scope="col">البريد الالكتروني </th>
      <th class="text-center table-primary" scope="col"> رقم الهاتف </th>
      <th class="text-center table-primary" scope="col"> العمليات  </th>


       
    </tr>
  </thead>
  <tbody>
    <?php 
   include 'dbcon.php';
   

   
  $sql="select *from users";
  $resault=mysqli_query($conn,$sql);
   
    $resault=mysqli_query($conn,$sql);
    while($row=mysqli_fetch_array($resault))
    {
      $id=$row['id'];
     

      
        echo '<tr > 
              <td class="text-center  "> '.$row['id'].' </td>
              <td class="text-center "> '.$row['name'].' </td>
             <td class="text-center ">  '.$row['email'].' </td> 
             <td class="text-center ">  '.$row['phone'].' </td>
             

            <td  class="text-center"> <button class="btn btn-primary  my-3"> <a href="update.php?updateid='.$id.'" class="text-light text-decoration-none"> تعديل</a> </button> 
            <button class="btn btn-danger confirm"  id="delete-row"> <a href="delete.php?deleteid='.$id.'" class="text-light text-decoration-none delete">حدف </a> </button> 
            <button class="btn btn-success" id="download" onclick="printPage(10)">طباعة</button>            
            </td>
          

             </tr>';

    }
    ?>
  </tbody>
  
</table>
    </div>
    
     
    <script>
        let s = document.querySelectorAll('.delete');
        for (i = 0; i < s.length; ++i) {
            s[i].addEventListener('click', (e) => {
                e.preventDefault();
                Swal.fire({
                    title: "Do you want to save the changes?",
                    showDenyButton: true,
                    confirmButtonText: "حذف",
                    denyButtonText: "الغاء"
                }).then((result) => {
                    if (result.isConfirmed) {
                        window.location = e.target.href;
                    } else if (result.isDenied) {
                        Swal.fire("لم يتم الحذف", "", "info");
                    }
                });
                
            });
        }
</script>
</body>
</html>

 

بتاريخ 6 دقائق مضت قال gamal_king:
<button class="btn btn-danger confirm"  id="delete-row"> <a href="delete.php?deleteid='.$id.'" class="text-light text-decoration-none">حدف </a> </button> 

الخطأ هنا حيث لم تقم بتعديل هذا السطر كما قام المدرب مصطفى بتعديله ليتناسب مع كود الجافا سكريبت

رابط هذا التعليق
شارك على الشبكات الإجتماعية

  • 0
بتاريخ 44 دقائق مضت قال محمد عاطف11:

قم باستخدام هذا الكود واخبرنى بالنتيجة

!DOCTYPE html>
<html lang="ar" dir="rtl">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>الرئيسية</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet"
    integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
    <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>

</head>
<body>
    <div class="container">
<table class="table my-5  table-bordered table-striped">
  <thead>
  <button class="btn btn-success mt-3"><a href="index.php" class="text-decoration-none text-light" >اضافة بيانات </a>  </button>

    <tr>
      <th class="text-center  table-primary" scope="col">#</th>
      <th class="text-center table-primary" scope="col">  الاسم</th>
      <th class="text-center table-primary"  scope="col">البريد الالكتروني </th>
      <th class="text-center table-primary" scope="col"> رقم الهاتف </th>
      <th class="text-center table-primary" scope="col"> العمليات  </th>


       
    </tr>
  </thead>
  <tbody>
    <?php 
   include 'dbcon.php';
   

   
  $sql="select *from users";
  $resault=mysqli_query($conn,$sql);
   
    $resault=mysqli_query($conn,$sql);
    while($row=mysqli_fetch_array($resault))
    {
      $id=$row['id'];
     

      
        echo '<tr > 
              <td class="text-center  "> '.$row['id'].' </td>
              <td class="text-center "> '.$row['name'].' </td>
             <td class="text-center ">  '.$row['email'].' </td> 
             <td class="text-center ">  '.$row['phone'].' </td>
             

            <td  class="text-center"> <button class="btn btn-primary  my-3"> <a href="update.php?updateid='.$id.'" class="text-light text-decoration-none"> تعديل</a> </button> 
            <button class="btn btn-danger confirm"  id="delete-row"> <a href="delete.php?deleteid='.$id.'" class="text-light text-decoration-none delete">حدف </a> </button> 
            <button class="btn btn-success" id="download" onclick="printPage(10)">طباعة</button>            
            </td>
          

             </tr>';

    }
    ?>
  </tbody>
  
</table>
    </div>
    
     
    <script>
        let s = document.querySelectorAll('.delete');
        for (i = 0; i < s.length; ++i) {
            s[i].addEventListener('click', (e) => {
                e.preventDefault();
                Swal.fire({
                    title: "Do you want to save the changes?",
                    showDenyButton: true,
                    confirmButtonText: "حذف",
                    denyButtonText: "الغاء"
                }).then((result) => {
                    if (result.isConfirmed) {
                        window.location = e.target.href;
                    } else if (result.isDenied) {
                        Swal.fire("لم يتم الحذف", "", "info");
                    }
                });
                
            });
        }
</script>
</body>
</html>

 

الخطأ هنا حيث لم تقم بتعديل هذا السطر كما قام المدرب مصطفى بتعديله ليتناسب مع كود الجافا سكريبت

 يعمل

رابط هذا التعليق
شارك على الشبكات الإجتماعية

انضم إلى النقاش

يمكنك أن تنشر الآن وتسجل لاحقًا. إذا كان لديك حساب، فسجل الدخول الآن لتنشر باسم حسابك.

زائر
أجب على هذا السؤال...

×   لقد أضفت محتوى بخط أو تنسيق مختلف.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   جرى استعادة المحتوى السابق..   امسح المحرر

×   You cannot paste images directly. Upload or insert images from URL.

  • إعلانات

  • تابعنا على



×
×
  • أضف...