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

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -