PHP Mysql creating HTML tables

I am currently building a website that will display car specs that are in a database. (The website is http://www.mymazdacx7.com/specs.php)

The main problem I am having is when I go to echo the results from the database table it only displays information from the first row.

The code is
[php]echo ‘

’; // Table Starts Here
while ( $row = mysql_fetch_assoc($sql))
{
				for ( $number = 0 ; $number < $field_num ; $number++) 
				{
					echo "<tr>";
					$columnnames = mysql_field_name($sql, $number);
					echo "<td>".$columnnames."</td>"; // Prints out Column Name!
					
							//The following while loop is a test
							
								echo "<td>". $row[$columnnames]."</td>";
								echo "<td>". $row[$columnnames]."</td>";
					echo "</tr>";
								}
				}

echo “

”;
[/php]

Now I have gone back and fourth between google and my code to try and fix it but I am currently at the point of pulling all my hair out. I really need some help here because I am not sure of the problem.
Reading up I believe it has something to do with the pointer being reset to the begining in one of the loops but I have no idea how to fix that problem.

Can you post the full code? (Including SQL query).

Also, just to be safe, output mysql_num_rows on the query:

[php]echo mysql_num_rows($sql);[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service