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

  • Home
  • SEARCH
  • 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 8496555
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T23:53:13+00:00 2026-06-10T23:53:13+00:00

Basically I’ve retrieved data from mysql on 1 line and made it look like

  • 0

Basically I’ve retrieved data from mysql on 1 line and made it look like a table with borders and stuff but I’d want it to repeat for every row on the mysql table. Here’s the following code I’ve used so far:

while($info = mysql_fetch_array( $data )) 
 { 
 echo "<table width='1000' cellpadding='10' cellspacing='5' border='1'>"; 

 echo "<tr>


    <td><center><b>".$info['id']."</td></center></b>"."<td><center><b>".$info['username']."</td></center></b>"."<td><center><b>".$info['kills']."</td></center></b>"."<td><center><b>".$info['deaths']."</td></center></b>"."<td><center><b>".$info['ratio']."</td></center></b></tr>"; 

 echo "</table>"; 
 } 

UPDATE:

 echo "<table width='1000' cellpadding='10' cellspacing='5' border='1'>"; 
 while($info = mysql_fetch_array( $data )) 
 { 
 echo "<tr> 
    <td><center><b>".$info['id']."</td></center></b>"."<td><center><b>".$info['username']."</td></center></b>"."<td><center><b>".$info['kills']."</td></center></b>"."<td><center><b>".$info['deaths']."</td></center></b>"."<td><center><b>".$info['ratio']."</td></center></b></tr>"; 

 } 
 echo "</table>"; 
  • 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-10T23:53:14+00:00Added an answer on June 10, 2026 at 11:53 pm

    You want the table tage outside the loop that fetches the rows of data:

    echo "<table width='1000' cellpadding='10' cellspacing='5' border='1'>"; 
    while($info = mysql_fetch_array( $data )) 
    { 
        echo "<tr>
        <td><center><b>".$info['id']."</td></center></b>"."<td><center><b>".$info['username']."</td></center></b>"."<td><center><b>".$info['kills']."</td></center></b>"."<td><center><b>".$info['deaths']."</td></center></b>"."<td><center><b>".$info['ratio']."</td></center></b></tr>"; 
    } 
    echo "</table>"; 
    

    As you are new to PHP I should probably expand this out a little more:

    Your code will now echo out the table opening tag:

    <table width='1000' cellpadding='10' cellspacing='5' border='1'>
    

    Then go into the while loop and echo out all the rows that it finds:

    <tr><td><center><b>Something1></b></td></tr> // shortened for example.
    <tr><td><center><b>Something2></b></td></tr>
    <tr><td><center><b>Something3></b></td></tr>
    <tr><td><center><b>Something4></b></td></tr>
    

    Then when it exists the loop, it will output the closing tag for the table:

    </table>
    

    What you were previously doing was outputting a table for each and every row of data. For future reference, it is a good idea to look into your source code to get an understanding of what is happening.

    Edit: When I was going through your code comment, I formatted it out neater to see what was going on, you might want to make your code easier to read by having the following format:

    echo "<table width='1000' cellpadding='10' cellspacing='5' border='1'>"; 
    while($info = mysql_fetch_array( $data )) 
    { 
        echo "<tr> 
            <td><center><b>".$info['id']."</b></center></td>
            <td><center><b>".$info['user‌​name']."</b></center></td>
            <td><center><b>".$info['kills']."</b></center></td>
            <td><center><b>".$info['deaths']."</b></center></td>
            <td><center><b>".$info['‌​ratio']."</b></center></td>
            </tr>"; 
    } 
    echo "</table>";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically from a database I am getting data that is formatted like this nameofproject101
Basically i'd like to allow an arbitrary (but not empty ) number of key-value
Basically, what I want is to access the data between substrings (between name: and
Basically if I want to transform a name from stephen smith to Stephen Smith
Basically, I want to get and display the data of a midi note (the
Basically what i am trying to do here is to read from the table
Basically I want to check the extended permissions the user has granted my app.
Basically I want to convert a virtual path to an absolute path.
basically I want to validate whether or not a text box is a certain
Basically I've made a form in Cakephp 2.1 with a jQuery button that appends

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.