I.Jokhadze I.Jokhadze - 10 months ago 55
PHP Question

Php can't get foreign key object id

i'm trying to get foreign key object id but it's not working.

$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>";

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

There have no space after $conn

Try it without space:

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