This is my code:
$query2 = "select * from teaches where teacherid_fk LIKE '$teacherid_fk'";
$userinfo2 = mysqli_query($conn, $query2);
while ($line = mysqli_fetch_assoc($userinfo2)) {echo json_encode($line);}
Somehow, the result I'm getting is only one array when there should be two arrays displayed. I need both arrays to be displayed, but my code only displays the second array. This is the db: dbTableofTeaches
Am I doing something wrong here? Just recently learned PHP and any help is deeply appreciated. :)
EDIT 2: If I do the code like this:
$query2 = "select * from teaches where teacherid_fk LIKE '$teacherid_fk'";
$userinfo2 = mysqli_query($conn, $query2);
$row = mysqli_fetch_array($userinfo2);
echo json_encode($row);
The result is this: {"teaches_id":"2","teacherid_fk":"1","subjectid_fk":"65","quarterid_fk":"1","gradeid_fk":"5","sectionid_fk":"13","schoolyearid_fk":"2"} [which is actually the first array I was looking for!]
EDIT 3: Okay I'm getting more confused. I've tried to edit the db so it now looks like this: dbTableOfTeaches2. With the same (first) code above, I refreshed the page, and the second and third arrays are now displayed, but still no sign of the first array! The only way I was able to display the first array was use the second code above.