Jump to content
Sigmahokies

why while print last row? I need to print all record

Recommended Posts

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

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...