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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T22:40:02+00:00 2026-06-12T22:40:02+00:00

I am trying to make a table via PHP, but when I load this,

  • 0

I am trying to make a table via PHP, but when I load this, it displays it like this..

printscreen

The code:

<table border="1" cellpadding="5">
<?php
while($test= mysql_fetch_assoc($countquery)){
        echo '<tr><td>';
    echo $test["count"];
    echo 'x</td>';
};
while($row=mysql_fetch_array($topresult)) {
    echo '<td width="150">';
    echo $row["productnaam"];
    echo '</td><td width="100" style="text-align:center;">&euro; ';
    echo $row["prijs"];
    echo '</td><td width="50" style="text-align:center;">';
    echo '<a style="text-decoration:none;color:red;" href="#"><img width="25" src="trash.png"></a>';
    echo '</td></tr>';
};
?>
</table>

My goal is to display a table of 4 columns by 3 rows..

EDIT:
Found it already, it makes a new <tr> tag everytime the first while is performed.

  • 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-12T22:40:03+00:00Added an answer on June 12, 2026 at 10:40 pm

    The block :

    while($test= mysql_fetch_assoc($countquery)){
            echo '<tr><td>';
        echo $test["count"];
        echo 'x</td>';
    };
    

    will create 3 cells 1x, 1x, 2x first,
    next the block:

     while($row=mysql_fetch_array($topresult)) {
        echo '<td width="150">';
        echo $row["productnaam"];
        echo '</td><td width="100" style="text-align:center;">&euro; ';
        echo $row["prijs"];
        echo '</td><td width="50" style="text-align:center;">';
        echo '<a style="text-decoration:none;color:red;" href="#"><img width="25" src="trash.png"></a>';
        echo '</td></tr>';
    };
    

    will create cells from Monitor, so the result become like this.
    To fix it, you should save the result from the first while loop to an array and go through at the 2nd while loop

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

Sidebar

Related Questions

I am currently trying to make a sectioned table like this: Section 1: Entry
I'm trying to make a cgridview that can filter data from relations table. This
I'm trying to update a tuple in a table using php and sql via
I'm trying to make table rows collapse if they contain no data. The rows
I am trying to make a table cell that when tapped calls a phone
I am trying to make a schedule table that would delete certain rows according
I'm trying to make a truth-table generator for a digital electronics course because that's
I am trying to make a contacts table in SQLite. When i commit the
I am trying to make a pivot table with rollup and a case statement
I'm trying to follow http://www.foliotek.com/devblog/make-table-rows-sortable-using-jquery-ui-sortable/ And have created a very simple example http://jsfiddle.net/6wbZQ/ It's

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.