# Displaying results in a table

**URL:** https://forum.kirupa.com/t/displaying-results-in-a-table/237254
**Category:** programming
**Created:** [August 28, 2007, 5:38pm UTC](https://forum.kirupa.com/t/displaying-results-in-a-table/237254 "2007-08-28T17:38:27Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![rondog](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/rondog/32/2478_2.png) [@rondog](https://forum.kirupa.com/u/rondog)
#### Post date: [August 28, 2007, 5:38pm UTC](https://forum.kirupa.com/t/displaying-results-in-a-table/237254/1 "2007-08-28T17:38:27Z")

</div>

Hey guys I am trying to get some results from my DB and display them in a table. When I look at it, it shows up blank (nothing in the source code either). If I take it out of the while loop and call it through an array I can get the single results. Here is my code.

```php

<?php
session_start();
if($_SESSION['trackerIn'] != 'yes')
    {           
header("Location: trackerlog.php");
    }
?>
<html>
<head>
<title>Untitled Document</title>
</head>
<body>
<?php
$con = mysql_connect("localhost","username","password");
if (!$con) {
    echo "unable to connect to DB";
    echo mysql_error($con);
    exit();
}
$db = mysql_select_db("datron");
if (!$db) {
    echo "unable to open DB";
    echo mysql_error($db);
    exit();
}
$havelogged = "SELECT username FROM users where loggedin = 'yes';";
$loggedrs = mysql_query($havelogged);
echo "<table>";
while ($loggedrow = mysql_fetch_array($loggedrs))
    {
echo "<tr><td>$loggedrow['username']</td><td>$loggedrow['loggedin']</td></tr>";
    }
echo "</table>";    
?>
</body>
</html>

```
