Hi all, i have written delete operation.......but its not deleting...........here is the code.......can u explain me whats wrong

<? 
session_start();
include('database.php');
$mailid1 = $_GET['mail_id']; 
session_register("mailid1");
$query1="SELECT * FROM  autoalto_mail where mail_id='".$mailid1."'";
$result = mysql_query( $query1 );

while($row = mysql_fetch_array($result))
{ 
	echo $row['subject'];
}
mysql_close();
?>
</b></td>
<td align="right" colspan="3" style="padding-left:5px;" class="headtitle"> 
<a href="Contractor_reply.php"><b>Reply</b></a><span >/</span>
<a href="contractor_mail_delete_action.php"><b>Delete</b></a><span>/</span>
<a href="lll.html"><b>Next</b></a></td></tr>
<tr><td><b><font size="2"><span style="color:005D95">From:</span></b>
<? 
session_start();
include('database.php');
$mailid1 = $_GET['mail_id']; 
$query1="SELECT * FROM  autoalto_mail where mail_id='".$mailid1."'";
$result = mysql_query( $query1 );

while($row = mysql_fetch_array($result))
{ 
	echo $row['From_user'];
}
mysql_close();
 ?>										
</b></td></tr>
</table>
</td></tr>

<tr><td>
<? 
session_start();
include('database.php');
$mailid1 = $_GET['mail_id']; 
$query1="SELECT * FROM  autoalto_mail where mail_id='".$mailid1."'";
$result = mysql_query( $query1 );
//echo mysql_num_rows($result) ;
while($row = mysql_fetch_array($result))
{ 
    echo $row['contents'];
}
mysql_close();
?>
<? 
session_start();
include('database.php');
$mailid1 = $_GET['mail_id']; 
$query1="DELETE FROM autoalto_mail  where mail_id='".$mailid1."'";
$result = mysql_query( $query1 );
//echo mysql_num_rows($result) ;

mysql_close();
?>

Recommended Answers

All 7 Replies

$query1="DELETE FROM autoalto_mail where mail_id=$mailid1";

check out and reply

you didn't mention any id to delete :

<a href="contractor_mail_delete_action.php"><b>Delete</b></a>

and print this: echo $_GET; in your contractor_mail_delete_action.php page .

Hi,

Can you tell, what is wrong with the delete operation, is it giving an error or what.

The syntex is correct.
You can print the sql syntex and then run the query in mysql directly.

Hi its displaying the value.......echo $_GET; but its not deleting

first try in mysql with delete opration like:

DELETE FROM autoalto_mail where mail_id=25

use the mail_id which is in your table....

if its work ,then notify me...

This Contractor_mail_action_contents.php

<?php
session_start();
include('database.php');
$result = mysql_query("SELECT * FROM  autoalto_mail" );
	
while($row = mysql_fetch_array($result))
 {
	?>
	<tr>
		<td width="5%"></td>
		<td><? echo $row['From_user'];?>					
		<td><a href="contractor_mail_action_contents.php?mail_id=<? echo $row['mail_id'];?>">			
		<?echo $row['subject'];
		$subj=$row['subject'];	
		session_register("subj");?> </a></td>
		<td><?echo $row['date']?></td>
	</tr>
	<tr>
		<td width="5%"></td>			
		<td colspan="4" style="background-repeat: repeat-x;" background="images/dot.jpg" height="0" width="300"></td>
	</tr>
	<?		
}
mysql_close();
?>


<? 
session_start();
include('database.php');
$mailid1 = $_GET['mail_id']; 
echo $_GET['mail_id'];

$query1="SELECT * FROM  autoalto_mail where mail_id='".$mailid1."'";
$result = mysql_query( $query1 );
//echo mysql_num_rows($result) ;
while($row = mysql_fetch_array($result))
{ 
    echo $row['contents'];
}
mysql_close();
?>

This is Contractor_mail_delete_action.php

<?php
session_start();
include('database.php');
$result = mysql_query("SELECT * FROM  autoalto_mail" );
	
while($row = mysql_fetch_array($result))
 {
	?>
	<tr>
		<td width="5%"></td>
		<td><? echo $row['From_user'];?>					
		<td><a href="contractor_mail_action_contents.php?mail_id=<? echo $row['mail_id'];?>">			
		<?echo $row['subject'];
		$subj=$row['subject'];	
		session_register("subj");?> </a></td>
		<td><?echo $row['date']?></td>
	</tr>
	<tr>
		<td width="5%"></td>			
		<td colspan="4" style="background-repeat: repeat-x;" background="images/dot.jpg" height="0" width="300"></td>
	</tr>
	<?		
}
mysql_close();
?>


<? 
session_start();
include('database.php');
$mailid1 = $_GET['mail_id']; 
$query1="DELETE FROM autoalto_mail  where mail_id='".$mailid1."'";
$result = mysql_query( $query1 );
//echo mysql_num_rows($result) ;

mysql_close();
?>

Its not deleting.........

please provide your database table....

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.