php - While statement only echoing last result -
i new, having small problem.. cannot while loop loop through entire result set, retrieving last result set, , expecting 2 result sets.
i echo'd query out see result get, , echo printed out both result sets want print out. leading me confusion while loop issue.
i have looked through lost on here posts have seen problem query, rather while loop. assistance appreciated. have used different posts on here construct query, don't know go here.
date_default_timezone_set("europe/london"); $date = jddayofweek(unixtojd()); $sql = "select * tbl id = $id , day = $date"; $results = $conn->query($sql); echo $sql; if ($results->num_rows > 0) { while ($row = $results->fetch_assoc()) { $output = "test2" . "</br>" . $row["time"] . "</br>"; } } else { $output = $output . "test1" . "</br>"; } }
you not echoing inside while loop.
i think need concatenate variable $output
.
while ($row = $results->fetch_assoc()) { $output .= "test2" . "</br>" . $row["time"] . "</br>"; }
Comments
Post a Comment