in my page i allow the administrator to list all user records with radio buttons...and he can delete record one by one using the radio button in front of the record and clicking delete button..the radio button has the value of primary key of record to be deleted..i post that value to another form and perform query operation to delete the specified record..but itz not working..
it shows error message:incorrect sql syntax..i think the problem is with radio button's value..kindly help me out of this..
<?php
include("dbconnect.php"); //for connecting database
include("printing.php"); //for printing query results
echo"<form action=\"confirm_deletus.php\" method=\"post\">"; //posted to another form
echo"<input type=\"submit\" value=\"deleteuser\" name=\"del\">";
$query="select * from users";
$re=mysql_query($query) or die
(mysql_error());
printresults($re); //list the users
echo"</form>";
?>
//confirm_deletus.php
<?php
include("dbconnect.php");
$uid=$_POST["user_id"]; //user_id is the primary key got from the value of radio button
$query="delete from users where user_id=$uid";
$re=mysql_query($query) or
die(mysql_error());
?>
//printing.php
<?php
function printresults($res)
{
if($p=mysql_num_rows($res)==0)
echo"no records found";
else
{
echo "<table bgcolor=#fffffff border=1 width=80%>";
while($p=mysql_fetch_array($res, MYSQL_NUM))
{
echo"<tr>";
while(list($key,$value)=each($p))
{
echo"<td valign=top align=left> $value </td>";
}
echo"</tr>"; //the radio button 's value is set to the primary key
echo"<input type=radio //of record
name=\”user_id\” value=\””.$p[“user_id”].”\”";
}
echo"</table>";
}
}
?>