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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T18:00:41+00:00 2026-06-15T18:00:41+00:00

RESOLVED Works perfectly! Here is my final code: <table> <thead> <tr> <?php $row =

  • 0

RESOLVED

Works perfectly! Here is my final code:

<table>
  <thead>
    <tr>
      <?php
      $row = mysql_fetch_assoc($result);
            foreach ($row as $col => $value) {
                echo "<th>";
                echo $col;
                echo "</th>";
            }
      ?>
      <th>Edit</th>
    </tr>
  </thead>
  <tbody>
    <?php
  // Write rows
  mysql_data_seek($result, 0);
    while ($row = mysql_fetch_assoc($result)) {
        ?>
    <tr>
      <?php         
    foreach($row as $key => $value){
        echo "<td>";
        echo $value;
        echo "</td>";
    }
    ?>
      <td><button id="edit_project_button(<?php echo $row['ID']; ?>)" class="edit-project-button edit button" onclick="editproject(<?php echo $row['ID']; ?>)">Edit</button></td>
    </tr>
    <?php } ?>
  </tbody>
</table>

I wish to echo out a HTML table using mysql_fetch functions appropriately. I plan on making a thead to contain the mysql table column names and a tbody to contain the mysql table resultset. The SQL query selects a couple of columns from the table, with default limit set.

The issue: It doesn’t seem to print the first row of table data, everything else displays (record #1 missing)

It displays the with column names echo’d within each , it then skips the first record and successfully echo’s the 2nd row onward. For example:

| id | firstname | lastname | date_start | date_end   | clientid | members | edit          |
|  2 | Cal       | Clark    | 2012-12-12 | 2012-12-12 | 22       | Rob     | (edit button) |
|  3 | Rob       | Robin    | 2012-12-12 | 2012-12-12 | 33       | Cal     | (edit button) |

I’m 100% sure that the first record will display from my query in phpmyadmin.

Here is my code:

<table>
  <thead>
    <tr>
      <?php
        $row = mysql_fetch_assoc($result);
            foreach ($row as $col => $value) {
                echo "<th>";
                echo $col;
                echo "</th>";
            }

      ?>
      <th>Edit</th>
    </tr>
  </thead>
  <?php
  // Write rows
  while ($row = mysql_fetch_array($result)) {
    ?>
  <tr>
    <td><?php echo $row[0]; ?></td>
    <td><?php echo $row[1]; ?></td>
    <td><?php echo $row[2]; ?></td>
    <td><?php echo $row[3]; ?></td>
    <td><?php echo $row[4]; ?></td>
    <td><?php echo $row[5]; ?></td>
    <td><?php echo $row[6]; ?></td>
    <td><button id="edit_project_button(<?php echo $row[0]; ?>)" class="edit-project-button edit button" onclick="editproject(<?php echo $row[0]; ?>)">Edit</button></td>
  </tr>
  <?php } ?>
</table>

I feel so oblivious right now =/

  • 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-15T18:00:43+00:00Added an answer on June 15, 2026 at 6:00 pm

    make a rewind of your data first!!

    mysql_data_seek($result, 0);
    while ($row = mysql_fetch_array($result)) {
    ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is my Google Maps code (it works perfectly by itself): <table width=99%> <tr><td
In concrete5 (PHP CMS) I created a basic Facebook comment block which works perfectly
This code works perfectly, except - dialog window will not close after X miliseconds
I resolved a code issue with a gem, but how do I then use
I have a simple Spring & Jersey application, which works perfectly well for consuming
The app works perfectly fine on the simulator and on the device. After adding
UPDATE As Mathias notes below, this exact problem has been reported and resolved here:
PySide is installed successfully, and it works perfectly, but I can't find a way
When I load the page, my scrollview works perfectly, but when I navigate away
So I have this newsfeed system which works perfectly on all browsers except IE8!

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.