Hi,
I am current;y developing a cms (for school).
In some area I have a table where I present all the general announcements that have been inserted by users.
From the table the users will be able to choose to delete, modify of change the state of the announcement (active/inactive). .
I am working on delete but it’s not getting me anywhere whith what I have done…
I have done the following
[CODE]
<?php
session_start();
if(!session_is_registered(“authenticated”)){
header(“location:login.php”);
}
include(“include/config.inc.php”);
include(“include/functions.php”);
include(“Classes/class.FastTemplate.php3”);
$tpl=new FastTemplate(“templates”);
$tpl->define(array(“index”=>”main_tpl.tpl”,
“ver_nav_dep”=>”vertical_nav_dep.tpl”,
“ver_nav_phd”=>”vertical_nav_phd.tpl”,
“table_pub”=>”table_pub.tpl”,
“row_title_pub”=>”row_title_pub.tpl”,
“row_pub”=>”row_pub.tpl”,
“table_auth”=>”table_auth.tpl”,
“row_title_auth”=>”row_title_auth.tpl”,
“row_auth”=>”row_auth.tpl”));
$con=mysql_connect($dbServer, $dbUser, $dbPass)
or exit(“<html>
<head>
<meta http-equiv=”Content-Type” content=”text/html;charset=windows-1253″>
</head>
<body>
<h2 align=center>Error!</h2>
</body>
</html>”);
//valid assignment for insert general_announce
$author_id=$_SESSION[“id”];
if($_SESSION[“type”]==”admin” || $_SESSION[“type”]==”pub”){
$active=1;
$temp=”;
}
else{
$active=0;
$temp=”temp_”;
}
//PRESENTATION OF GENERAL ANNOUNCEMENTS IN THE MAIN PAGE OF GENERAL ANNOUNCEMENTS
else{
$tpl->assign(“{USER}”,$_SESSION[“username”]);
$page_name=”Γενικές Ανακοινώσεις”;
$tpl->assign(“{PAGE_NAME}”,$page_name);
switch($_SESSION[“group”]){
case “Melos DEP”:
$tpl->assign(“{H_NAVIGATION}”,”);
$tpl->assign(“{TREE}”,”treemenu1″);
$tpl->parse(“{V_NAVIGATION}”,”.ver_nav_dep”);
break;
case “Phd”:
$tpl->assign(“{H_NAVIGATION}”,”);
$tpl->assign(“{TREE}”,”treemenu1″);
$tpl->parse(“{V_NAVIGATION}”,”.ver_nav_phd”);
break;
}//end switch
$sql=”SELECT DISTINCT g.id AS id,
g.title_gr AS title,
g.author_id AS author_id,
g.date AS date,
g.active AS active,
p.inter_name_gr AS name
FROM general_announce g, (SELECT id, inter_name_gr FROM personnel WHERE id=’$author_id’ OR supervisor_id=’$author_id’) p
WHERE g.author_id=p.id
ORDER BY date DESC”;
$res=mysql_db_query($dbDatabase,$sql);
if(mysql_num_rows($res)==’0′){
$tpl->assign(“{CONTENT}”,”<center><h3>No Announcements</center></h3>”);
}
if ($res && mysql_num_rows($res)){
if($_SESSION[“type”]==”pub”){
while($result=mysql_fetch_array($res)){
$tpl->assign(“{TITLE}”,stripslashes($result[“title”]));
$tpl->assign(“{AUTHOR}”,stripslashes($result[“name”]));
$tpl->assign(“{MOD}”,”<a href=”general_announce.php?modify=true&id=”.$result[“id”].””><img width=”15″ height=”16″ src=”images/edit.png” alt=”Αλλαγή” title=”Αλλαγή” border=”0″/></a>”);
$tpl->assign(“{DEL}”,”<a href=”general_announce.php?delete=true&id=”.$result[“id”].”” onclick=”return confirmLink(this,’Do u want to delete this announcement?’)”><img width=”15″ height=”16″ src=”images/recycle.png” alt=”Delete” title=”Διαγραφή” border=”0″/></a>”);
if($result[“active”]==”0″){
$tpl->assign(“{ACTIVE}”,”<a href=”general_announce.php?activate=yes&id=”.$result[“id”].”” onclick=”return confirmLink(this, “Do u want to activate this announcement;”)”><img width=”15″ height=”16″ src=”images/stop.png” alt=”Ενεργοποίηση” title=”Κάντε κλικ για ενεργοποίηση” border=”0″/></a>”);
}
if($result[“active”]==”1″){
$tpl->assign(“{ACTIVE}”,”<a href=”general_announce.php?activate=no&id=”.$result[“id”].”” onclick=”return confirmLink(this, ‘Do u want to deactivate this announcement?’)”><img width=”15″ height=”16″ src=”images/apply.png” alt=”Απενεργοποίηση” title=”Κάντε κλικ για απενεργοποίηση” border=”0″/></a>”);
}
$tpl->parse(“{ROWS}”,”.row_pub”);
}
$tpl->assign(array(“{H_TITLE}”=>”General Announcement”,
“{H_AUTHOR}”=>”Author”,
“{H_MOD}”=>”Modify”,
“{H_DEL}”=>”Delete”,
“{H_ACTIVE}”=>”State”
));
$tpl->parse(“{ROW_TITLE}”,”.row_title_pub”);
$tpl->parse(“{CONTENT}”,”table_pub”);
}//end if publisher
$tpl->parse(“MAIN”,”index”);
$tpl->FastPrint();
}
//DELETE GENERAL ANNOUNCEMENT FUNCTIONALITY
if(isset($_GET[“delete”]) && $_GET[“delete”]==”true” && isset($_GET[“id”])){
$sql=”DELETE FROM general_announce WHERE id='”.$_GET[“id”].”‘”;
$res=mysql_db_query($dbDatabase,$sql);
if($res) {header(“Location:general_announce.php”);}
else header(“Location:index.php”);
//delete content
}
?>
The problems I am facing with this piece of code are the following
– when I click on the delete icon I don’t get the confirmLink Window
– the page redirect/reloads as defined in the delete loop but the item I chose to delete is still in the list of general announcements but not in the database…. then if i click on the delete again it will finally disappear from the list and the same will happen if i reload the page
Any suggestions what to do to make it work?
Thanx in advance
Yona