Sigmahokies Posted November 16, 2019 Share Posted November 16, 2019 Hi everyone, I'm trying to display all record in php from database, there are three rows in phpmyadmin already, but why while won't print three rows? it just printed last row. what did I do wrong? I followed exactly from w3school's instruct, but it is still show last row, not all record. $show = "SELECT FirstName, LastName, City, State, TimeZone FROM sampleDB"; $query = mysqli_query($GaryDB, $show); if(mysqli_num_rows($query)) { while($row = mysqli_fetch_assoc($query)) { $display = "<tr><td>".$row['FirstName']."</td><td>".$row['LastName']."</td><td>".$row['City']."</td><td>".$row['State']."</td><td>".$row['TimeZone']."</td></tr>"; } } else { $display = "<tr><td>None of record in database</td></tr>"; } mysqli_close($GaryDB); Can you help? Thanks, Gary Link to comment Share on other sites More sharing options...
dsonesuk Posted November 16, 2019 Share Posted November 16, 2019 $display= overwrites the prev output, you need to append to prev output with $display.= 1 Link to comment Share on other sites More sharing options...
Sigmahokies Posted November 16, 2019 Author Share Posted November 16, 2019 dsoneuk, You are right, it works now...thank you so much! Gary Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now