Jump to content

[SOLVED] displaying databasae in table some missing


gathos

Recommended Posts

ok so when i try to display my database info in a table of 3 columns, it display 1 2 3 5 6

 

i'm getting it to show the id's of the entries, make debuggin easier. so why does it skip 4? here's my code

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
</head>

<body>
<?
mysql_connect("localhost","username","password");
mysql_select_db("database");
// these were changed to protect my username password and database

$result=mysql_query("select * from traddb order by id asc");

Echo "<table border='1'>";
while($row=mysql_fetch_assoc($result)){
echo "<tr>
<td>";
echo $row['id'];
$row=mysql_fetch_assoc($result);
echo"
</td>
<td>";
echo $row['id'];
$row=mysql_fetch_assoc($result);

echo"
</td>
<td>";
echo $row['id'];
$row=mysql_fetch_assoc($result);
echo "
</td>
</tr>";
}
echo "</table>";

?>
</body>
</html>

 

so any reason why this might happen? thanks.

 

later days,

gathos

Try this (note that it is "air code" :))

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
</head>

<body>
<?
mysql_connect("localhost","username","password");
mysql_select_db("database");
// these were changed to protect my username password and database

$result=mysql_query("select * from traddb order by id asc");

$count = 1;
echo "<table border=\"1\">";
while($row = mysql_fetch_assoc($result)) {
if ($count == 1) {
	echo "<tr>";
}
echo "<td>" . $row["id"] . "</td>";
if ($count == 4) {
	echo "</tr>";
	$count = 0;
}
$count++;
}

echo "</table>";

?>
</body>
</html>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.