Jump to content

Recommended Posts

My html form:

news_list.php

 

 

<?php
include("admin.php");
include("connection.php");
$sql=mysql_query("select * from news order by id");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
 
<body>
<!--<form name="frm" action="news_delete.php" method="post">-->
<div align="center" style="width:700px; height:auto; float:left;border:solid 1px #DCDCDC; margin-top:20px;"><!--main div-->
 
<div align="center" style="width:700px; height:auto; float:left;border:solid 1px #DCDCDC;">
<div align="center" style="width:50px; height:auto; float:left;border:solid 1px #DCDCDC;">NO</div>
<div align="center" style="width:300px; height:auto; float:left;border:solid 1px #DCDCDC;">NEWS</div>
</div>
 
<div align="center" style="width:300px; height:auto; float:left;border:solid 1px #DCDCDC;">
<?php
if($sql>0)
{
while($row=mysql_fetch_array($sql))
{
$id=$row['id'];
$msg=$row['details'];
?>
 
 
<div align="center" style="width:700px; height:auto; float:left;border:solid 1px #DCDCDC;">
<div align="center" style="width:50px; height:auto; float:left;border:solid 1px #DCDCDC;"><?php echo $id?></div>
<div align="center" style="width:300px; height:auto; float:left;border:solid 1px #DCDCDC;"><?php echo $msg?></div>
<div align="center" style="width:100px; height:auto; float:left;border:solid 1px #DCDCDC;"><a href="news_edit.php">EDIT</a></div>
<!--<div align="center" style="width:100px; height:auto; float:left;border:solid 1px #DCDCDC;"><button onclick="window.location.href='news_delete.php'">DELETE</button></div>-->
<div align="center" style="width:50px; height:auto; float:left;border:solid 1px #DCDCDC;"><a href="news_delete.php?id=$id">delete</a></div>
<!--<div align="center" style="width:50px; height:auto; float:left;border:solid 1px #DCDCDC;"><input name="delete" type="submit" value="DELETE"/></div>
-->
<?php
}
}
?>
</div>
 
</div>
 
 
<div align="center" style="width:100px; height:auto; float:left; margin-left:550px;"><a href="news.php">ADD NEW</a></div>
</div><!--main div ends-->
<!--</form>-->
</body>
</html>
 

news_delete.php

 

 

<?php
include('connection.php');
if(isset($_GET['id']))
{
$id=$_GET['id'];
$query1=mysql_query("delete from news where id='$id'");
if($query1)
{
header('location:news_list.php');
}
}
?>

 

on clicking the button(delete) control rem,aining in news_list page.what is the problem in this code?

sir,

i cannt get you.please explain.

i commented 2 delete buttons.bt 1 delete button which is working is not commented.

next i commented form description.

i think form can be optional because using href i called the page where the control has to move.

i removed comment of the form.

<div align="center" style="width:50px; height:auto; float:left;border:solid 1px #DCDCDC;"><a href="news_delete.php?id=$id">delete</a></div>

removed ?id=$id from a href.now the connection is moving to news_delete.php.bt cannt delete the value.

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.