I am using Windows XP as my OS and apache server. I have successfully inserted new records into database using forms and now want to delete the records from the database through using radio buttons.
Any record i'll select with radio button should be deleted on submit.
[code=php]
<HTML>
<HEAD>
<TITLE>New Document</TITLE>
</HEAD>
<BODY>
<? php
if($_GET["cmd"]=="delete")
{
$sql = "DELETE FROM stuinfo WHERE FirstName=$Firs tName";
$result = mysql_query($sq l);
echo "Row deleted!";
}
?>
</BODY>
</HTML>
[/code]
Any record i'll select with radio button should be deleted on submit.
Code:
<?
//connect to mysql
//change user and password to your mySQL name and password
mysql_connect("localhost","root","root");
//select which database you want to edit
mysql_select_db("mydb");
//If cmd has not been initialized
if(!isset($cmd))
{
//display all the news
$result = mysql_query("select * from stuinfo order by FirstName");
//run the while loop that grabs all the news scripts
while($r=mysql_fetch_array($result))
{
//grab the title and the ID of the news
//$title=$r["title"];//take out the title
$FirstName=$r["FirstName"];//take out the id
//make the title a link
echo "<a href='delete.php?cmd=delete&FirstName=$FirstName'></a>";
echo "<br>";
}
}
?>
<HTML>
<HEAD>
<TITLE>New Document</TITLE>
</HEAD>
<BODY>
<? php
if($_GET["cmd"]=="delete")
{
$sql = "DELETE FROM stuinfo WHERE FirstName=$Firs tName";
$result = mysql_query($sq l);
echo "Row deleted!";
}
?>
</BODY>
</HTML>
[/code]
Comment