Jump to content

Displaying DB Rows in a table.


waynew

Recommended Posts

Okay, when I use this page, all I get is... nothing. Not even the Title of the page will show. What do you think?

 

<?php session_start(); ?>

<!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>Users</title>
</head>

<body><?php
$user="*******";
$password="********";
$database="*********";
$conn = mysql_connect("*************" ,$user,$password);
@mysql_select_db($database, $conn) or die(mysql_error);

$result = mysql_query("SELECT * FROM USERS");

echo = "<TABLE>";

while($row = mysql_fetch_array($result))
  {
  echo "<tr>";
  echo "<td>" . $row['ID'] . "</td>";
  echo "<td>" . $row['NAME'] . "</td>";
  echo "<td>" . $row['USERNAME'] . "</td>";
  echo "<td>" . $row['EMAIL'] . "</td>";
  echo "</tr>";
  }
  
echo "</TABLE>";


mysql_close($conn);

?>

</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/103438-displaying-db-rows-in-a-table/
Share on other sites

Here's the current code:

 

$result = mysql_query("SELECT ID, EMAIL, NAME, USERNAME FROM USERS");

echo = "<TABLE>";

while($row = mysql_fetch_array($result))
  {
  echo "<tr>";
  echo "<td>" . $row['ID'] . "</td>";
  echo "<td>" . $row['NAME'] . "</td>";
  echo "<td>" . $row['USERNAME'] . "</td>";
  echo "<td>" . $row['EMAIL'] . "</td>";
  echo "</tr>";
  }
  
echo "</TABLE>";


mysql_close($conn);

?>

</body>
</html>

Try this as well:

 

<?php session_start(); ?>

<!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>Users</title>
</head>

<body>
<TABLE>
<th>ID</th>
<th>NAME</th>
<th>USERNAME</th>
<th>EMAIL</th>
<?php
$user="*******";
$password="********";
$database="*********";
$conn = mysql_connect("*************" ,$user,$password);
@mysql_select_db($database, $conn) or die(mysql_error);

$result = mysql_query("SELECT * FROM USERS",$conn);

while($row = mysql_fetch_array($result))
  {
  echo "<tr>";
  echo "<td>" . $row['ID'] . "</td>";
  echo "<td>" . $row['NAME'] . "</td>";
  echo "<td>" . $row['USERNAME'] . "</td>";
  echo "<td>" . $row['EMAIL'] . "</td>";
  echo "</tr>";
  }
  
mysql_close($conn);

?>
</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.