Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8380003
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T16:20:35+00:00 2026-06-09T16:20:35+00:00

I have a table in a SQL database with the following fields: ID, Name,

  • 0

I have a table in a SQL database with the following fields: ID, Name, Email, University, Languages, and Experience. I want to create an html table that fetches data from SQL and outputs the last 10 results? How would I do that?

I’m sorry if this is a very simple question, I have very little knowledge in PHP and SQL.

Here’s the code I have right now that just displays the name and not in a table:

    <html>
    <head>
        <title>Last 5 Results</title>
    </head>
    <body>
        <?php
            $connect = mysql_connect("localhost","root", "root");
            if (!$connect) {
                die(mysql_error());
            }
            mysql_select_db("apploymentdevs");
            $results = mysql_query("SELECT * FROM demo");
            while($row = mysql_fetch_array($results)) {

                echo $row['Name'] . "</br>";


            ?>
    </body>
</html>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T16:20:36+00:00Added an answer on June 9, 2026 at 4:20 pm

    Here is something that should help you to create the table and get more knowledge of php and mysql.

    Also you should move your connection logic and query to the beginning of your process, thus avoiding errors while loading the page and showing a more accurate error than just the mysql_error.

    Edit: If your ids are incrementing, then you could add the ORDER BY clause,

    change: SELECT * FROM demo LIMIT 10
    to: SELECT * FROM demo LIMIT 10 ORDER BY id

    <html>
        <head>
            <title>Last 10 Results</title>
        </head>
        <body>
            <table>
            <thead>
                <tr>
                    <td>Id</td>
                    <td>Name</td>
                </tr>
            </thead>
            <tbody>
            <?php
                $connect = mysql_connect("localhost","root", "root");
                if (!$connect) {
                    die(mysql_error());
                }
                mysql_select_db("apploymentdevs");
                $results = mysql_query("SELECT * FROM demo LIMIT 10");
                while($row = mysql_fetch_array($results)) {
                ?>
                    <tr>
                        <td><?php echo $row['Id']?></td>
                        <td><?php echo $row['Name']?></td>
                    </tr>
    
                <?php
                }
                ?>
                </tbody>
                </table>
        </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a SQL database that has the following table: Table: PhoneRecords -------------- ID(identity
I have a EMP table in my database with the following fields: id,name,post,joining_date. Whenever
I have a following scenario in my SQL Server 2005 database. zipcodes table has
Ok I have a table in my SQL Server database that stores comments. My
I have a SQL database that has a table with a field set to
I have the following database structure: Sites table id | name | other_fields Backups
I have the following database structure: CREATE TABLE LookupTable ( PK UNIQUEIDENTIFIER PRIMARY KEY,
I have a table created with PHP from an Sql Database that successfully displays
I have a database table named 'favoritecats' with the following fields: id catName catId
I have the following table in a SQL Server 2008 database with lots of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.