First and foremost thank you for taking a look at my question. This is somewhat one of my first MySql/PHP projects and wondering if there was a way to condense these two pages I have created.

Basically I have a MySql database with some dummy filler info in. I have created a php page that displays the info:

```
<?php
// Connect to server and select database.
$link = mysqli_connect("localhost", "root", "password", "testdelete"); //for local machine testing

// Check connection
if($link === false){
    die("ERROR: Could not connect. " . mysqli_connect_error());
}

// select record from mysql 
$sql = "SELECT id, name, lastname, email FROM testdelete.test_mysql";
$result = $link->query($sql);

if ($result->num_rows > 0) {

    include 'table_header.html';
     // output data of each row
     while($row = $result->fetch_assoc()) {

         echo "<tr>";
         echo "<td bgcolor=\"#FFFFFF\">".$row["id"]."</td>";
         echo "<td bgcolor=\"#FFFFFF\">". $row["name"]."</td>";
         echo "<td bgcolor=\"#FFFFFF\">" . $row["lastname"]."</td>";
         echo "<td bgcolor=\"#FFFFFF\">". $row["email"] . "</td>";
         echo "<td bgcolor=\"#FFFFFF\"><a href=\"test_delete_ac.php?id={$row['id']}\">Delete row</a></td>";
         echo "</tr>";

     }

     include 'table_footer.html';
} else {
     echo "0 results";
}

// close connection
mysqli_close($link);

?>

```

Based on the code sample, each row of data displays and there is a column for the delete button so I can delete a row when I want. However, the way it is set up now is it calls a secondary page "test\_delete\_ac.php" as shown below:

```
<?php

// Connect to server and select database.
$link = mysqli_connect("localhost", "root", "password", "testdelete"); //for local machine testing

// Check connection
if($link === false){
    die("ERROR: Could not connect. " . mysqli_connect_error());
}

// select record from mysql 
//$sql = "SELECT id, name, lastname, email FROM testdelete.test_mysql";
//$result = $link->query($sql);

// get value of id that sent from address bar 
$id=$_GET['id'];

// Delete data in mysql from row that has this id 
$sql="DELETE FROM testdelete.test_mysql WHERE id='$id'";
$result=$link->query($sql);

// if successfully deleted
if($result){
echo "Deleted Successfully";
echo "<BR>";
echo "<a href='delete.php'>Back to main page</a>";
}

else {
echo "ERROR";
}

// close connection
mysqli_close($link);

?>

```

One for usability I want to limit it from going to a secondary page, and having to click the "go back" link. And two can I create a function and call it from the link to delete the row and still show the form? Like the page reloads or something?

Thanks in advance for any redirection any of you may be able to offer.

-Kate