Displaying MySQL data using PHP
Generally speaking, you should keep your markup and your PHP logic separate.

And the intermediate variables don't really have a purpose, just use the values from the array.

You've got two opening form tags and no closing form tags.

Your first condition (i there are records in the table) does not close the thead or the create a tbody.

Your delete button is no button at all, it's an input wrapped in an anchor tag (&lt;a&gt;). That's why it's not working as expected. Either remove the anchor and give the input a type attribute of "button", or remove the input and put some text in there instead.

Use a prepared statement. It's not cool to throw variables into your queries all willy-nilly. You will anger the code gods.

Here's a quick re-write (assumes you're using PDO - If you're using MySQLi, see the docs to convert the prepared statement to MySQLi)

I'm just going to go ahead and post this since i spend three or four minutes on it, but after looking at this code, there is no way this was working as you had it. This site is for reviewing working code, not fixing broken code. If your code doesn't work you need to ask on StackOverflow in the future.

&lt;?php

    // Do all the PHP stuff before you start ouputting
    $noLists = "&lt;div&gt;You have no lists. Why dont you create one?&lt;/div&gt;";

    if ($db-&gt;connect_error) {
        die("Connection failed: " . $db-&gt;connect_error);
    }

    $sql = "SELECT DISTINCT lists.id, lists.listdescription, lists.createdon, lists.createdby, lists.sharedlist FROM lists INNER JOIN users ON users.fname = ? AND users.fname = lists.createdby";
    $result = $db-&gt;prepare($sql);
    $result-&gt;execute(array($displayname));
    $output = array();
    if ($result-&gt;rowCount() &gt; 0) {
        // output data of each row

        $output[] = "&lt;/thead&gt;";
        $output[] = "&lt;tbody&gt;";

        while($row = $result-&gt;fetch(PDO::FETCH_ASSOC)) {

            $output[] = "&lt;tr&gt;";
            $output[] = "&lt;td&gt;{$row["listdescription"]}&lt;/td&gt;";
            $output[] = "&lt;td&gt;{$row["createdon"]}&lt;/td&gt;";
            $output[] = "&lt;td&gt;{$createdBy}&lt;/td&gt;";
            $output[] = "&lt;td align=\"right\"&gt;";
            $output[] = "&lt;form action='account.php' method='post'&gt;";
            $output[] = "&lt;input class=\"btn btn-success\" type=\"submit\" name=\"\" value=\"Edit\"&gt;";
            $output[] = "&lt;/form&gt;";
            $output[] = "&lt;a href='includes/deletelist.php?id={$row["id"]}' class=\"btn btn-danger\" style=\"width: 85px;\"&gt;Delete&lt;/a&gt;&lt;/td&gt;";
        }

        $output[] = "&lt;/tbody&gt;";
        $output[] = "&lt;/table&gt;";

    } else {
        $output[] = "&lt;/thead&gt;";
        $output[] = "&lt;tbody&gt;";
        $output[] = "&lt;/tbody&gt;";
        $output[] = "&lt;/table&gt;";
        $output[] = "&lt;h4&gt; $noLists&lt;/h4&gt;";
    }
    $db-&gt;close();

    // Turn the output array back into a string
    $output = implode('', $output);

?&gt;&lt;div class="container" style="width: 95%;"&gt;
    &lt;table class="table table-bordered table-striped table-hover"&gt;
        &lt;thead&gt;
            &lt;tr&gt;
                &lt;th class="col-sm-6"&gt;
                    Description
                &lt;/th&gt;
                &lt;th class="col-sm-2"&gt;
                    Date Created
                &lt;/th&gt;
                &lt;th class="col-sm-1"&gt;
                    Created By
                &lt;/th&gt;
                &lt;th class="col-sm-2" style="text-align: right;"&gt;
                    Edit - Delete
                &lt;/th&gt;
            &lt;/tr&gt;
        &lt;?php echo $output; ?&gt;


Edit... you're not closing your table row in the loop either. I'm not gonna bother updating the code snippet.