Been working on this for a while; Need to select data from a table where the ID column matches the ID from another table.
My code so far:
<?php
$sql = "SELECT * FROM input";
$sql2 = "SELECT * FROM output WHERE question_id =".$row["id"];
$result = $conn->query($sql);
$result2 = $conn->query($sql2);
if ($result->num_rows > 0) {
$index = 0;
while($row = $result->fetch_assoc()) {
$index++;
?>
<?php
echo '<input type="hidden" name="questionid" value="'. $row['id'].'"/>';
?>
<?php
if ($result2->num_rows > 0) {
while($row2 = $result2->fetch_assoc()) {
}
} else {
echo "0 results";
}
}
} else {
echo "0 results";
}
$conn->close();
?>
I know I m missing something important here. Any suggestions are appreciated.