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 8658853
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T15:52:00+00:00 2026-06-12T15:52:00+00:00

Why is my MySQL data not being displayed in my table? Everything seems to

  • 0

Why is my MySQL data not being displayed in my table? Everything seems to work fine except that my data (which is a list of bird names and such) isn’t showing up. I need some fresh eyes who can see where my mistake is, and yes I know that there are probably easier ways to do this, but this is what is required for my assignment, so please don’t offer other ways to do this. All I need is help getting my data to populate in the HTML table. My PHP code is below:

PHP Code

<?php
    $pageTitle = 'Mod06 Pagination| Jason McCoy ';
    include('includes/header.inc.php');
    include ('includes/db_connect.inc.php');

    $display = 8;

    // Determine how many pages there are...

    if (isset($_GET['p']) && is_numeric($_GET['p'])) { // Already been determined.
        $pages = $_GET['pages'];
    } else { 
        $query = "SELECT COUNT(birdID) FROM birds";
        $result = @mysqli_query($dbc, $query);
        $row = @mysqli_fetch_array($result, MYSQLI_NUM);
        $records = $row[0];
    }

    // Calculate the number of pages...

    if ($records > $display) { 
        $pages = ceil($records/$display);
    } else {
        $pages = 1;
    }

    // Determine where in the database to start returning results...

    if (isset($_GET['s']) && is_numeric($_GET['s'])) {
        $start = $_GET['s'];
    } else {
        $start = 0;
    }

    // Sort the columns 
    // Default is birdID

        $sortDefault = 'birdID';

        // Create an array for the columns

        $sortColumns = array('birdID', 'nameGeneral', 'nameSpecific', 'populationTrend');

        // Define sortable query ASC DESC

        $sort =  (isset($_GET['sort'])) && in_array($_GET['sort'], $sortColumns) ? $_GET['sort']: $sortDefault;
        $order = (isset($_GET['order']) && strcasecmp($_GET['order'], 'DESC') == 0) ? 'DESC' : 'ASC';

        // Run the query 

    $query = "SELECT birdID, nameGeneral, nameSpecific, populationTrend FROM birds ORDER BY $order LIMIT $start, $display";
    $result = @mysqli_query($dbc, $query);       
?>

    <!-- Table header: -->
    <table align="center" cellspacing="0" cellpadding="5" width="80%">
        <tr>
            <th><a href='index.php?sort=birdID&order=<?php echo $order == 'DESC' ? 'ASC' : 'DESC' ?>'>Bird<?
                            if($_GET["order"]=="ASC" && $_GET["sort"]=="birdID"){
                                echo '<img src="images/downArrow.jpg" id="birdASC" name="birdASC" style="margin:-15px 0 0 13px;" width="18px" height="18px">';
                            } else {
                    echo '<img src="images/upArrow.jpg" id="birdDESC" name="birdDESC" style="margin:-15px 0 0 13px;" width="18px" height="18px">';
                }?></a></th>
            <th><a href='index.php?sort=nameGeneral&order=<?php echo $order == 'DESC' ? 'ASC' : 'DESC' ?>'>General Name<?
                            if($_GET["order"]=="ASC" && $_GET["sort"]=="nameGeneral"){
                                echo '<img src="images/downArrow.jpg" id="nameGeneralASC" name="nameGeneralASC" style="margin:-15px 0 0 13px;" width="18px" height="18px">';
                            } else {
                    echo '<img src="images/upArrow.jpg" id="nameGeneralDESC" name="birdDESC" style="margin:-15px 0 0 13px;" width="18px" height="18px">';
                }?></a></th>
            <th><a href='index.php?sort=nameSpecific&order=<?php echo $order == 'DESC' ? 'ASC' : 'DESC' ?>'>Name Specific<?
                            if($_GET["order"]=="ASC" && $_GET["sort"]=="nameSpecific"){
                                echo '<img src="images/downArrow.jpg" id="nameSpecificASC" name="nameSpecificASC" style="margin:-15px 0 0 13px;" width="18px" height="18px">';
                            } else {
                    echo '<img src="images/upArrow.jpg" id="nameSpecificDESC" name="birdDESC" style="margin:-15px 0 0 13px;" width="18px" height="18px">';
                }?></a></th>
            <th><a href='index.php?sort=populationTrend&order=<?php echo $order == 'DESC' ? 'ASC' : 'DESC' ?>'>Population Trend<?
                            if($_GET["order"]=="ASC" && $_GET["sort"]=="populationTrend"){
                                echo '<img src="images/downArrow.jpg" id="populationTrendASC" name="populationTrendASC" style="margin:-15px 0 0 13px;" width="18px" height="18px">';
                            } else {
                    echo '<img src="images/upArrow.jpg" id="populationTrendDESC" name="birdDESC" style="margin:-15px 0 0 13px;" width="18px" height="18px">';
                }?></a></th>
        </tr>
<?php

    // Display the database results in the table...

    while ($row = @mysqli_fetch_array($result, MYSQL_ASSOC)) {
        echo '<tr>
            <td align="left">$row[birdID]</td>
            <td align="left">$row[nameGeneral]</td>
            <td align="left">$row[nameSpecific]</td>
            <td align="left">$row[populationTrend]</td>
         <tr>';
    } 

    echo '</table>';    
    mysqli_close($dbc);

    // Make the links to other pages, if necessary.
    if ($pages > 1) {
        echo '<br /><p>';
        $currentPage = ($start/$display) + 1;
    // If it's not the first page, make a Previous button:
    if ($currentPage != 1) {
        echo '<a href="index.php?s=' . ($start - $display) . '&pages=' . $pages . '&sort=' . $sort . '">Previous</a> ';
    }
    // Make all the numbered pages:
    for ($i = 1; $i <= $pages; $i++) {
        if ($i != $currentPage) {
            echo '<a href="index.php?s=' . (($display * ($i - 1))) . '&pages=' . $pages . '&sort=' . $sort . '">' . $i . '</a> ';
        } else {
            echo $i . ' ';
        }
    } // End of FOR loop.

    // If it's not the last page, make a Next button:
    if ($currentPage != $pages) {
        echo '<a href="index.php?s=' . ($start + $display) . '&pages=' . $pages . '&sort=' . $sort . '">Next</a>';
    }

    echo '</p>'; 

} 

    include('includes/footer.inc.php');
?>


</div>
</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-12T15:52:02+00:00Added an answer on June 12, 2026 at 3:52 pm

    Change this one $row[birdID] to $row['birdID'] for all, you missed ''.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im not sure how to output MySQL data into formats below. (eg: timelist, usersex,
Why can't the data in mysql not updated when I use checkbox, I already
Iam trying to retrieve data from mysql database into stylesheet.php but it is not
I am fetching data from mysql to a page, i am not sure if
I have a list of products from a particular supplier being displayed in a
I have a mysql query which outputs 6 columns of related data, I'm specifically
I have 3 tables. Table A contains the data that my query is going
I am reading (mysql) data to display on the view using ruby on rails.
I have MYSQL data like this id | number 1 | 3 4 |
[...] public DataSet ReturnPromoMagazinesDs() { MySql.Data.MySqlClient.MySqlConnection mysqlConnection = new MySql.Data.MySqlClient.MySqlConnection(this.connectionString); MySql.Data.MySqlClient.MySqlCommand mysqlCommand = new

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.