Help needed to delete the entry form the table format
Posted: Wed Aug 25, 2010 1:29 am
Hello friends
i am showing data in table format in my application. i have used while loop to show that table. for every request i am showing a DELETE button so that once that request is over i can delete that particular entry from the database. peroblem is , i am not able to delete the entry ::::::: below is the code i m using
i am showing data in table format in my application. i have used while loop to show that table. for every request i am showing a DELETE button so that once that request is over i can delete that particular entry from the database. peroblem is , i am not able to delete the entry ::::::: below is the code i m using
Code: Select all
$query = "SELECT * FROM `software`";
$result=mysql_query($query) or die("Query failed!");
if(mysql_num_rows($result))
{
while($data=mysql_fetch_array($result,MYSQL_ASSOC)) //$line=mysql_fetch_array($paymajor,MYSQL_ASSOC)
{
$sno=$data['SNO'];
$name=$data['NAME'];
$id=$data['ID'];
$hostel=$data['HOSTEL'];
$software=$data['SOFTWARE'];
$url=$data['URL'];
$size=$data['SIZE'];
if($count==1)
{
?>
<table width="300" border="2" align="center" cellpadding="5" style="border: solid 2px black;" >
<tr bgcolor="#CCCCCC"><td colspan="10"><strong><center>BITS - PILANI, K.K. Birla GOA CAMPUS</center></strong></td></tr>
<tr bgcolor="#CCCCCC"><td colspan="10"><strong><center>Details of Software Request</center></strong></td></tr>
<tr bgcolor="#CCCCCC">
<td><center><strong>SNO</strong></center></td>
<td><center><strong>NAME</strong></center></td>
<td><center><strong>ID</strong></center></td>
<td><center><strong>HOSTEL</strong></center></td>
<td><center><strong>SOFTWARE</strong></center></td>
<td><center><strong>URL</strong></center></td>
<td><center><strong>SIZE</strong></center></td>
<td><center></center></td>
</tr>
<?php
}
if($sno>0)
{
echo '<tr><td><center>'.$sno.'</td></center>
<td><center>'.$name.'</center></td>
<td><center>'.$id.'</center></td>
<td><center>'.$hostel.'</center></td>
<td><center>'.$software.'</center></td>
<td><center><a href="'.$url.'" target="_blank" >'.$url.'</a></center></td>
<td><center>'.$size.'</center></td>
<td><input type="submit" name="delete" value="Delete" ></td></tr>';
}
$count++;
}
}
<?php
echo "here $sno";
if(isset($_POST['delete']))
{
global $sno;
$query="DELETE FROM software WHERE SNO='$sno'";
mysql_query($query) or die ("Error in deleting table");
echo"<center><br><br>software table record deleted successfully<center>";
}
?>