Jump to content

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:

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.