2012-08-26 85 views
0
$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(主鍵)(只有一個)。如何獲取以前查詢過的一行MySQL主鍵?

+0

你能告訴樣品表中的數據和你希望獲取什麼樣本? 「SELECT *」返回完整的行,包括任何主鍵的字段。 – Nilpo

回答

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