Php无法获取外键对象id

时间:2016-10-23 11:57:59

标签: php

我正在尝试获取外键对象ID,但它无效。

$sql2 = "SELECT a.*, q.* FROM answer a inner join question q on a.question_id = q.id WHERE a.question_id = 1";

$result2 = $conn ->query($sql2);

while($row2 = $result2->fetch_assoc()) {
    echo "<input name='group1' type='radio' id='". $row2['id'] ."' />" . "<label for='". $row2['id'] ."'>".$row2['answer_text']."</label>";
}

1 个答案:

答案 0 :(得分:1)

$result2 = $conn ->query($sql2);

$conn

之后没有空格

无空间地尝试:

$result2 = $conn->query($sql2);