/    Sign up×
Community /Pin to ProfileBookmark

problem when trying to delete a piece of content

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=”&#915;&#949;&#957;&#953;&#954;&#941;&#962; &#913;&#957;&#945;&#954;&#959;&#953;&#957;&#974;&#963;&#949;&#953;&#962;”;
$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=”&#913;&#955;&#955;&#945;&#947;&#942;” title=”&#913;&#955;&#955;&#945;&#947;&#942;” 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=”&#916;&#953;&#945;&#947;&#961;&#945;&#966;&#942;” 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=”&#917;&#957;&#949;&#961;&#947;&#959;&#960;&#959;&#943;&#951;&#963;&#951;” title=”&#922;&#940;&#957;&#964;&#949; &#954;&#955;&#953;&#954; &#947;&#953;&#945; &#949;&#957;&#949;&#961;&#947;&#959;&#960;&#959;&#943;&#951;&#963;&#951;” 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=”&#913;&#960;&#949;&#957;&#949;&#961;&#947;&#959;&#960;&#959;&#943;&#951;&#963;&#951;” title=”&#922;&#940;&#957;&#964;&#949; &#954;&#955;&#953;&#954; &#947;&#953;&#945; &#945;&#960;&#949;&#957;&#949;&#961;&#947;&#959;&#960;&#959;&#943;&#951;&#963;&#951;” 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
}
?>
[/CODE]

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

to post a comment
PHP

0Be the first to comment 😎

×

Success!

Help @yona_t spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...