如何获取以前查找的行的MySQL主键?

时间:2012-08-26 02:32:11

标签: 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(主键)(只有一行)。

1 个答案:

答案 0 :(得分:1)

添加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'];