Hey Guys,
I need some help with Deleting data from a MySQL .
Currently I have, Two PHP files.
the First is the main page.
<?php
$host="";
$username="";
$password="";
$db_name="";
$tbl_name="";
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$sql="SELECT * FROM $tbl_name";
$result=mysql_query($sql);
?>
<p>This Page Refreshes Every 10 Seconds</p>
<table width="500" border="0" cellspacing="1" cellpadding="0">
<tr>
<td><table width="200%" border="0" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<td colspan="7" bgcolor="#FFFFFF"><strong>Current Flight Plans using the GVA Flight Planner</strong> </td>
</tr>
<tr>
<td align="center" bgcolor="#FFFFFF"><strong>ID</strong></td>
<td align="center" bgcolor="#FFFFFF"><strong>Username</strong></td>
<td align="center" bgcolor="#FFFFFF"><strong>Tail Number</strong></td>
<td align="center" bgcolor="#FFFFFF"><strong>Departure Airport</strong></td>
<td align="center" bgcolor="#FFFFFF"><strong>Destination Airport</strong></td>
<td align="center" bgcolor="#FFFFFF"><strong>IFR or VFR</strong></td>
<td align="center" bgcolor="#FFFFFF"><strong>Cruising Altitude</strong></td>
<td align="center" bgcolor="#FFFFFF"><strong>Remarks</strong></td>
<td align="center" bgcolor="#FFFFFF"> </td>
</tr>
<?php
while($rows=mysql_fetch_array($result)){
?>
<tr>
<td bgcolor="#FFFFFF"><center><? echo $rows['ID']; ?></center></td>
<td bgcolor="#FFFFFF"><center><? echo $rows['Username']; ?></center></td>
<td bgcolor="#FFFFFF"><center><? echo $rows['TailNumber']; ?></center></td>
<td bgcolor="#FFFFFF"><center><? echo $rows['DepartureAirport']; ?></center></td>
<td bgcolor="#FFFFFF"><center><? echo $rows['DestinationAirport']; ?></center></td>
<td bgcolor="#FFFFFF"><center><? echo $rows['IFRorVFR']; ?></center></td>
<td bgcolor="#FFFFFF"><center><? echo $rows['CrustingAltitude']; ?></center></td>
<td bgcolor="#FFFFFF"><center><? echo $rows['Remarks']; ?></center></td>
<td bgcolor="#FFFFFF"><center><a href="delete_ac.php?id=<? echo $rows['id']; ?>">delete</a></center></td>
</tr>
<?
// close while loop
}
// close connection;
mysql_close();
?>
</table></td>
</tr>
</table>
And then I have my Delete_ac.php page with this
<?php
$host="";
$username="";
$password="";
$db_name="";
$tbl_name="";
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$id=$_GET['id'];
$sql="DELETE FROM $tbl_name WHERE id='$id'";
$result=mysql_query($sql);
if($result){
echo "Deleted Successfully";
echo "<BR>";
echo "<a href='Administrator.php'>Back to main page</a>";
}
else {
echo "ERROR";
}
mysql_close();
?>
And now My problem is when I click Delete on the Main page, it says it Deleted it Successfully but When I go back to the Main Page it still Shows the row the I clicked Delete on.
Can someone Please help me on why this is Happening? Thanks in Advance :)