In the website I'm designing the admin list page shows fields such as Name, Email, Username and Status(whether active or inactive users). My database has a table called admin. The fields are iAdminId, vFirstName, vLastName, vEmail, vUserName, vPassword, vFromIP, vFromIP, dLastLogin, and eStatus.

在我正在设计的网站中,管理列表页面显示了名称,电子邮件,用户名和状态(无论是活动用户还是非活动用户)等字段。我的数据库有一个名为admin的表。字段是iAdminId,vFirstName,vLastName,vEmail,vUserName,vPassword,vFromIP,vFromIP,dLastLogin和eStatus。

In the equivalent PHP page (the admin list page) I need to add a delete button. Check boxes are present with each row. The number of rows that an administrator chooses will be deleted (after confirmation, of course) once he/she clicks on Delete button. My problem is since I havent mentioned the iAdminId field in my listing page how do I uniquely identify each record?

在等效的PHP页面(管理列表页面)中,我需要添加一个删除按钮。每行都有复选框。管理员选择的行数将在他/她单击“删除”按钮后被删除(当然是在确认之后)。我的问题是因为我没有在我的列表页面中提到iAdminId字段如何唯一地标识每条记录?

My javscript code for deletion is:

我删除的javscript代码是:

function deleteRecord()
{
    var count = getCount();
    if(count == 0)
    {
      alert("Please enter some records for deletion first!!");
    }
    else
    {
      var c = confirm("Do you wish to delete?");
      if(c==true)
      {
        document.frm.mode.value="Delete";
        document.frm.submit();
      }
      else
      {
        alert("You had wrongly selected 'Delete' option!!");
      }
    }

  }

getCount returns the number of selected records. And PHP code is

getCount返回所选记录的数量。 PHP代码是

if($mode=="Delete")
{
    for($i=0;$i<count($_POST['ch']);$i++)
    {
      $delete = "DELETE FROM admin WHERE Name = '".$_POST["ch"][$i]."'";
      $result = mysql_query($delete);
    }
}

2 个解决方案

#1


2

Provided the email is unique to each user and you have checks to ensure this uniqueness, it can be used else, there is no foolproof way to do this. The only way is to place the id in the listing. This is the single unique identifier of each row since using a combination of any of the colums can be repeated. Another option is to create a composite primary key across two of the fields mentioned or a unique key on the email field.

如果电子邮件对每个用户都是唯一的,并且您有检查以确保这种独特性,那么可以使用它,没有万无一失的方法可以做到这一点。唯一的方法是将id放在列表中。这是每行的唯一唯一标识符,因为可以重复使用任何列的组合。另一种选择是跨所提到的两个字段或电子邮件字段上的唯一键创建复合主键。

Eg. To ensure that the email is unique or combinations of first name and surname is unique.

例如。确保电子邮件是唯一的,或者名字和姓氏的组合是唯一的。

更多相关文章

  1. 如何检查电子邮件id是否存在?
  2. 如果使用Select2 YII2选择第一个字段,请在下方自动填充字段
  3. Yii2之发送电子邮件
  4. 如何将多行数据插入到一个表字段中
  5. MySQL命名约定,字段名称是否应包含表名?
  6. 使用AJAX值的Fileupload不会以其他字段的形式传递
  7. Mysql 批量修改字段存储过程
  8. mysql中select列表可以有group列表中没有的字段,大家不觉得奇怪吗
  9. 如何将空值传递给外键字段?

随机推荐

  1. Android Linux 内核介绍
  2. Android Market新增运营商结算方式
  3. 解析Failure [INSTALL_FAILED_CONFLICTIN
  4. Android:保护自己开发的Android应用程序
  5. Android 的网络编程(17)-android显示网络
  6. 『ANDROID』android:layout_gravity和and
  7. [原]如何在Android用FFmpeg+SDL2.0解码显
  8. android中线程的应用
  9. Android服务器搭建——Jsp+Servlet,返回Js
  10. Android开发者指南(1) ―― Android Debu