Jump to content

Need Help regarding to Refreshing Page


kirtan007

Recommended Posts

Use the header() function to go to.. ManageProjects.php?deleteid=1&deleted=true. If delete=true is there, then it should display 'record 1 deleted' instead of deleting the record, very simple to do with IF's and GET's.

 

You have to place:

<?php 
ob_start(); //at top
//your code..
if (isset($_GET['deleted'])) {
    echo "Record ".$_GET['deleteid']." has been deleted!"
} else { 
    //delete record
    header(bla..&deleted=true);
}

at the top of your page, right after the <?php to be able to header if that's what you like, since the output buffer would stop you otherwise and throw an error.

<?php

   include("Connection.php");
   $result = mysql_query("Select * from projects",$con);
   $num = mysql_num_rows($result);
   $deleteid = $_REQUEST['deleteid'];
   
   if($deleteid != "")
   {
       $q = mysql_query("delete from Projects where ProjectID=" .$deleteid,$con);
       echo "Project Deleted !!";
       header('Location:ManagerProjects.php');
   }
      
   if ($num > 0)
   {
       echo "<table>";
       echo "<th>Project ID</th><th>Project Name</th><th>Project Description</th>";
       while($row = mysql_fetch_array($result))
       {
          echo "<tr>";
          echo "<td><center>" . $row['ProjectID'] . "<center></td>";      
          echo "<center><td>" . $row['ProjectName'] . "</td></center>";
          echo "<center><td>" . $row['ProjectDesc'] . "</td></center>";  
          echo "<center><td>" . $row['ProjectImage'] . "</td></center>";
          echo "<td><a href=ManageProjects.php?deleteid=" . $row['ProjectID'].">Delete</a></td>";      
          echo "</tr>";
       }
        echo "</table>" ;
   }
   else 
   {
       echo "No Record Found !!";
   }
      
      
?>
<a href="AddnewProjectForm.php">Add New Project</a>  

 

 

Hii Thanks for Reply Friend

 

Here is My Code

 

I Can delete the record from database but after deleting I have to manually Refresh the Page  :confused:

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.