I am trying to print the result of a mysqli query in PHP but it is only displaying the first line and there are multiple lines in the text field. Can you help me know what command I need to use?
Thank you.
result = $mysqli->query("SELECT someData FROM someTable WHERE id='Bob' AND group='TheGroup'");
$num_rows = $result->num_rows;
printf($num_rows." ");
if ($num_rows == 1) {
printf("In if...");
while($row = $result->fetch_row()) {
printf("%s", $row[0]);
}
}
According to your logic:
if ($num_rows == 1) {}
the control will only go to this part of the code if you are getting only one row back from the database. So the part where you display all the rows never gets executed.
This one should work just fine:
$i = 0;
while($row = $result->fetch_row()){
printf("%s", $row[$i]);
$i++;
}