Jump to content

Refresh on Delete


rainemaida

Recommended Posts

Once my delete has been performed I want the page to be refreshed. Here is what I have at the moment but when you delete something nothing happens the first time, however if you press delete again then it does refresh the page.

 

//DELETE RECORD

 

// Get the ID of the chosen thing and store it in a variable

$id = $_GET['id'];

 

// Store the update query string in a variable

    $delete="DELETE FROM coursedocument WHERE id='$id'";

 

// Execute delete

$deleted = mysql_query($delete);

 

if($deleted)

{

// Refresh the page

header("refresh: 0; url=coursedocumentsstaff.php");;

}

 

 

Cheers,

Steve

Link to comment
https://forums.phpfreaks.com/topic/45269-refresh-on-delete/
Share on other sites

No it doesn't work, the delete itself works but not refreshing the page afterwards. Here's the page, maybe something is interfering?

 

<head>
<style type="text/css">
p.leftmargin {margin-left: 2cm; margin-top: 1cm}
p.leftmargin1 {margin-left: 2cm;}
A:link {text-decoration: none;}
A:visited {text-decoration: none;}
A:active {text-decoration: none;}
A:hover {text-decoration: underline; color: red;}
</style>
<script language="javascript">

function confirmation(){
       if(!confirm("Are you sure you want to delete this item?")){
                 return false; 
       }

}
</script>
<link type="text/css" rel="stylesheet" href="blackboard.css" /></head>
<?php
//Connect to the database
require_once('db_connect.php');

// Get all the data from the "Course Documents Table" table
$result = mysql_query("SELECT * FROM coursedocument") or die(mysql_error());  

//DELETE RECORD

// Get the ID of the chosen thing and store it in a variable
$id = $_GET['id'];

// Store the update query string in a variable
     $delete="DELETE FROM coursedocument WHERE id='$id'";

 // Execute delete
$deleted = mysql_query($delete);

if($deleted)
{
	// Refresh the page
	header("Location: coursedocumentsstaff.php");
}





echo "<p class='leftmargin'><font face='arial'>Course Documents</p>";
echo "<img src='images/seperator.jpg' width='100%' height='20'>";
echo "<p class='leftmargin1'><a href='insert.php'><img src='images/additem.jpg' border='0'></a><a href='sendsms.php'><img src='images/sendSMS.jpg' border='0'></a></p>";
echo "<table border='0' width='90%' align='center' cellspacing='5' cellpadding='10'>";


// While loop to get all the Course documents until there are no left
while($row = mysql_fetch_array( $result )) {

// Print out the course documents into a table

echo "<tr><td width='13%' valign='top' align='center'>"; 
echo "<font color='black' size='2px' face='arial'>";
echo $row['id'];
echo ".";
echo "</td><td width='50%' valign='top'>"; 
echo "<font color='black' size='2px' face='arial'>";
echo $row['title'];
echo "<br />";
echo "<font color='black' size='2px' face='arial'>";
echo '<a href="uploads/'.$row['link'].'">';
echo $row['link'];
echo "</a>";
echo "</td><td width='18%' align='center' valign='middle'>"; 
echo "<font color='black' size='2px' face='arial'>";
//Allow user to modify the selected course document	
echo '<a href="edit.php?id='.$row['id'].'">Modify </a>';
echo "</td><td width='19%' align='center' valign='middle'>"; 
//Allow user to delete the selected course document
echo "<font color='black' size='2px' face='arial'>";
echo '<a href="coursedocumentsstaff.php?id='.$row['id'].'" onclick="javascript:return confirmation()">Remove </a>';
echo "</td>"; 
} 

echo "</table>";
?>

 

Cheers,

Steve

 

 

Link to comment
https://forums.phpfreaks.com/topic/45269-refresh-on-delete/#findComment-219820
Share on other sites

move the

 


<head>
<style type="text/css">
p.leftmargin {margin-left: 2cm; margin-top: 1cm}
p.leftmargin1 {margin-left: 2cm;}
A:link {text-decoration: none;}
A:visited {text-decoration: none;}
A:active {text-decoration: none;}
A:hover {text-decoration: underline; color: red;}
</style>
<script language="javascript">

function confirmation(){
       if(!confirm("Are you sure you want to delete this item?")){
                 return false; 
       }

}
</script>
<link type="text/css" rel="stylesheet" href="blackboard.css" /></head>

 

below the header command

Link to comment
https://forums.phpfreaks.com/topic/45269-refresh-on-delete/#findComment-219850
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.