php - 如何获取以前查找过的一行的MySQL主键?

标签 php mysql html css database

$query_check_domain_exists = "SELECT * FROM schools where domain ='$email_domain'";
$result_check_domain_exists = mysqli_query($d_schools, $query_check_domain_exists);
$school_ID_result = ?

$school_ID_result 变量需要包含它刚刚查找的行的 school_ID(主键)(只有一个)。

最佳答案

添加mysqli_fetch_assoc()然后从数组中获取 school_ID:

$query_check_domain_exists = "SELECT * FROM schools where domain ='$email_domain'";
$result_check_domain_exists = mysqli_query($d_schools, $query_check_domain_exists);
$row = mysqli_fetch_assoc($result);
$school_ID_result = $row['school_ID'];

关于php - 如何获取以前查找过的一行的MySQL主键?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12127198/

相关文章:

java - JDBC UPDATE With preparedStatement 导致 java.sql.SQLException : Parameter index out of range (3 > number of parameters, 这是 2)

javascript - 最持久的 HTML5 数据存储是什么?

html - 表格行填充剩余高度 Chrome vs. Firefox

html - chrome 中的奇数框

php - 在单独的页面上将数据从一种形式传递到另一种形式

php - (MySQL)需要从多个表中获取匹配分数,并按它们的分数之和排序

php - 使用主题标签计算推文数量

php - 在 MySQL 中处理多个图像

php - 将一组字符计数为一个单元的字符串排列

mysql - 如何实现跨多个表的行唯一的自增id?