0

Hey guys,

I have this code which gets some reults from a table and displays them:

echo "<table><tr>";

while($col = mysql_fetch_array($columns)){
echo "<th>".$col['COLUMN_NAME']."</th>";
}
echo "</tr>";
$i=0;
while($row = mysql_fetch_array($data)){
echo "<tr>";
foreach($row as $r){
echo "<td>".$r."</td>";
}
echo "</tr>";
}

echo "</table>";

Getting the column names is fine, but with the actual results it displays it twice for example:

Column1 Column2 Column3
result1 result1 result2 result2 result3 result3
result1 result1 result2 result2 result3 result3

Why is this happening?

Thanks in advance for any help. :)

3
Contributors
4
Replies
5
Views
5 Years
Discussion Span
Last Post by Wolxhound90
0

Can you please provide your mysql query?
It looks fine I think.
And if not, i've little bit strange solution.
But just for last chance.

0

my $data query is:

$data = mysql_query("SELECT * FROM ".$table) or die(mysql_error());

2

mysql_fetch_array() pulls the resource as an associative array and as a numbered array, try changing it to mysql_fetch_assoc()

Votes + Comments
good spot
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.