Approve or Deny Buttons

I have the following code below. I have added buttons to each entry that pops up but I need the buttons to do certain things and I’m stuck.

When the Approve button is pressed I want the entire entry to go to another table called “incomplete” (no quotations) and then I want the record to be deleted from the table “needs” (no quotations), which it currently resides in.

When the Deny button is pushed I want the entry to just be deleted from the table “needs” (no quotations).

Tried to figure it out on my own but I have nothing. I’m new to all this and the fact that I’ve gotten this far makes me excited :slight_smile:

[php]$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);

if (!$link) {
die('Could not connect: ’ . mysql_error());
}

$db_selected = mysql_select_db(DB_NAME, $link);

if (!$db_selected) {
die ('Cant use ’ . DB_NAME . ': ’ . mysql_error());
}

$query = mysql_query(“SELECT * FROM needs”);

while ($rows = mysql_fetch_array($query)):

$firstname = $rows[‘firstname’];
$lastname = $rows[‘lastname’];
$address = $rows[‘address’];
$city = $rows[‘city’];
$state = $rows[‘state’];
$phone = $rows[‘phone’];
$email = $rows[‘email’];
$typeofneed = $rows[‘typeofneed’];

echo “$firstname $lastname
$address
$city $state
$phone
$email
$typeofneed
”;
echo “Approvedeny
---------------------------
”;

endwhile;[/php]

I thought about making a delete.php file and using a link to delete the entry. Here is the current code for the main script that shows the data now:

$query = mysql_query("SELECT * FROM needs");
while ($rows = mysql_fetch_array($query)):
$id = $rows['ID'];
$firstname = $rows['firstname'];
$lastname = $rows['lastname'];
$address = $rows['address'];
$city = $rows['city'];
$state = $rows['state'];
$phone = $rows['phone'];
$email = $rows['email'];
$typeofneed = $rows['typeofneed'];
echo "$id<br>$firstname $lastname<br>$address<br>$city $state<br>$phone<br>$email<br>$typeofneed<br>";
echo "<a href=''>Approve</a>         <a href='delete.php?id=$id'>Deny</a><br>---------------------------<br>";
endwhile;

But what does the delete script need to look like? Would it be like this?

$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
if (!$link) {
die('Could not connect: ' . mysql_error());
}
$db_selected = mysql_select_db(DB_NAME, $link);
if (!$db_selected) {
die ('Cant use ' . DB_NAME . ': ' . mysql_error());
}

mysql_query("DELETE FROM needs WHERE ID=$id");

Thanks for the help. Just trying to figure it out.

Sponsor our Newsletter | Privacy Policy | Terms of Service