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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T13:54:25+00:00 2026-05-20T13:54:25+00:00

I am teaching myself PHP and MySQL, and I am trying to retrieve some

  • 0

I am teaching myself PHP and MySQL, and I am trying to retrieve some information from my database and put it into a table.

So far only the table column headers are showing up, and no information is showing up for each column. It is also taking ages for the PHP file to display.

Please can you point out the problem with my code.

<?php
mysql_connect("localhost",$username,$password);
mysql_select_db($dbname) or die("Unable to select Database");
$query = "SELECT * FROM table_1";
$result = mysql_query($query);
$numcount = mysql_num_rows($result);
echo "<h2>$numcount rows in table_1.</h2>";
mysql_close();
?>

<table border="0" cellspacing="4" cellpadding="2">
<tr>
<th><font face="Futura">Type |</font></th>
<th><font face="Futura">Name |</font></th>
<th><font face="Futura">Street |</font></th>
<th><font face="Futura">Address1 |</font></th>
<th><font face="Futura">Address2 |</font></th>
<th><font face="Futura">Town |</font></th>
<th><font face="Futura">County |</font></th>
<th><font face="Futura">Postcode |</font></th>
<th><font face="Futura">Number |</font></th>
<th><font face="Futura">Latitude,Longitude</font></th>
</tr>

<?php
$i=0;
while ($i < 843) {
$type = mysql_result($result,$i,"type");
$name = mysql_result($result,$i,"name");
$street = mysql_result($result,$i,"street");
$addr1 = mysql_result($result,$im,"address1");
$addr2 = mysql_result($result,$im,"address2");
$town = mysql_result($result,$im,"town");
$county = mysql_result($result,$im,"county");
$postcode = mysql_result($result,$im,"postcode");
$number = mysql_result($result,$im,"number");
$latlong = mysql_result($result,$im,"latlong");
}
?>

<tr>
<td><font face="Futura"><?php echo $type;?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><?php echo $name;?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><?php echo $street;?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><?php echo $addr1;?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><?php echo $addr2;?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><?php echo $town;?></font></td>
</tr>
<?php
$i++;
?>
<?
echo "</table>"; 
?>
</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-05-20T13:54:26+00:00Added an answer on May 20, 2026 at 1:54 pm

    For a starter, you are having an infinite loop as $i is not being incremented inside the loop. If you increment $i, it should fix the problem. What is $im?

    The code should look like:

    <?php
    $i=0;
    while ($i < 843) {
        $type = mysql_result($result,$i,"type");
        $name = mysql_result($result,$i,"name");
        $street = mysql_result($result,$i,"street");
        $addr1 = mysql_result($result,$i,"address1");
        $addr2 = mysql_result($result,$i,"address2");
        $town = mysql_result($result,$i,"town");
        $county = mysql_result($result,$i,"county");
        $postcode = mysql_result($result,$i,"postcode");
        $number = mysql_result($result,$i,"number");
        $latlong = mysql_result($result,$i,"latlong");
    
    ?>
    
    <tr>
    <td><font face="Futura"><?php echo $type;?></font></td>
    <td><font face="Arial, Helvetica, sans-serif"><?php echo $name;?></font></td>
    <td><font face="Arial, Helvetica, sans-serif"><?php echo $street;?></font></td>
    <td><font face="Arial, Helvetica, sans-serif"><?php echo $addr1;?></font></td>
    <td><font face="Arial, Helvetica, sans-serif"><?php echo $addr2;?></font></td>
    <td><font face="Arial, Helvetica, sans-serif"><?php echo $town;?></font></td>
    </tr>
    <?php
        $i++;
    } // this is where the loop is ending.
    ?>
    <?
    mysql_close(); // close mysql connection after reading data
    echo "</table>"; 
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I'm teaching myself Ruby on Rails, with a PHP background. I've written a
I'm teaching myself some basic scraping and I've found that sometimes the URL's that
I'm teaching myself Objective-C from a book ( Cocoa programming for mac OS X
I am in the very beginnings of teaching myself php. I am giving myself
not sure why my code wont work, im teaching myself javascript i know php
I am teaching myself some Python and I have come across a problem which
Teaching myself some c# and my problem is that I have a class which
I'm trying to teaching myself how to program by building programs/scrips that will be
I'm teaching myself Python and my most recent lesson was that Python is not
So I'm teaching myself Python, and I'm having an issue with lists. I want

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.