index.php
Code: Select all
<form method="get" action="delete.php"> //file is the name of this file
<?
mysql_pconnect("localhost","unknownz","password"); //connect to the mySQL
mysql_select_db("unz"); //select the db
if(!$submit)//if submit has not already been pressed
{
$result = mysql_query("select * from news order by id"); //select all the news
while($r=mysql_fetch_array($result)) //run the while loop
{
$title=$rї"title"];//take out the title
$id=$rї"id"];//take out the id
?>
<INPUT TYPE="RADIO" NAME="id" VALUE="<?php echo $id;?>"><br> //the radio button with the value of each id
<?php echo $id;?><br> //output the id
<?php echo $title?><br> //output the title
<?
}?> //end of the while loop
<input type="submit" value="submit" name="Submit"></form> //submit
<?
}?>Code: Select all
<?
else
{
$sql = "DELETE FROM news WHERE id=$id";
$result = mysql_query($sql);
echo "Record deleted!";
}?>