I am creating a system where records in a database need to be displayed in a HTML table.
The HTML table and getting data is working fine. 
However I need a column with a delete icon/link for each row. 
For example, row one will have a row of data and in the final column a X for delete. 
It was working fine previously, however now I need to update everything from MySQL to MySQLi. 
The old way of generating my table no longer works (using a for loop and php) and so I must use a while loop.

Please see my code.

```
<table align="center" cellpadding="10px">
<tr>
    <td>
        <?php
        echo "<table align=center; width=833; height=102; border=1>"; //begin table tag...

        echo "<tr bgcolor=#eeeeee>";
        echo "<td>" . "Locomotive" . "</td>";
        echo "<td>" . "Headcode" . "</td>";
        echo "<td>" . "Seen At" . "</td>";
        echo "<td>" . "Train Origin" . "</td>";
        echo "<td>" . "Train Destination" . "</td>";
        echo "<td>" . "On" . "</td>";
        echo "<td>" . "At" . "</td>";
        echo "<td>" . "Action" . "</td>";
        echo "</tr>";

        while ($rowitem = mysqli_fetch_array($dataresults)) {
            echo "<tr>";
            echo "<td>" . $rowitem['Class'] . $rowitem['Number'] . "</td>";
            echo "<td>" . $rowitem['Headcode'] . "</td>";
            echo "<td>" . $rowitem['SightedLocation'] . "</td>";
            echo "<td>" . $rowitem['TrainOrigin'] . "</td>";
            echo "<td>" . $rowitem['TrainDestination'] . "</td>";
            echo "<td>" . $rowitem['SightingDate'] . "</td>";
            echo "<td>" . $rowitem['SightingTime'] . "</td>";
            echo "<td>" . <a href = "SightingHome.php?d=1&id=<?php echo $rowitem['SightingID'] ?>" <img src = 'Images/delete.png' title = "Delete This Sighting" width = "25" height = "24" /> </td>;
            echo "</tr>";
        }
        echo "</table>";
        ?>
    </td>
</tr>

```

The problem is I am struggling to get the PHP inside the row for the action, the last echo in the bottom table. 

If anyone needs the full code I can provide it.

PS: dataresults is the following

```
    $UserName = $_SESSION['UserID'];
    $SightingData = "SELECT * from tblsightings WHERE UserID = '$UserName' ORDER BY SightingDate DESC" ;

    $dataresults = mysqli_query($connection,$SightingData);

```

I am just rebuilding the new system off a old system I already had however is been a few years since I did PHP.
New site <http://trainmania100.x10host.com/>