Using checkbox deleting the data from database

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
nithinkk
Forum Commoner
Posts: 55
Joined: Sat Nov 28, 2009 7:57 am

Using checkbox deleting the data from database

Post by nithinkk »

Code: Select all

<?


$con=mysql_connect("localhost","root","itsSecrect");
if(!$con)
{
die('Could not connect:' . mysql_error());
}




mysql_select_db("system",$con);
$result = mysql_query("select our_feedback.username,name,type,dept,batch,feedback from user_details, our_feedback where our_feedback.username=user_details.username;");


echo"<table border ='1'>
<tr>
<th>Delete</th>
<th>Username:</th>
<th>Name</th>
<th>Type</th>
<th>Department</th>
<th>Batch</th>
<th>Feedback</th>
</tr>";

while($row = mysql_fetch_array($result))
{
echo"<tr>";
echo "<td><input type=\"checkbox\" name=\"chkid_$i\"></td>";
echo"<td>".$row['username'] . "</td>";
echo"<td>".$row['name'] . "</td>";
echo"<td>".$row['type'] . "</td>";
echo"<td>".$row['dept'] . "</td>";
echo"<td>".$row['batch'] . "</td>";
echo"<td>".$row['feedback'] . "</td>";

echo"</tr>";
}
echo"</table>";

mysql_close($con);


?>	[text]This is my code which list all the feedback's from the user. I had insert a check box at the starting of each row..i want to add  a button which deletes the selected feedback from the database...can any one help me in coding this ?????[/text]
eruna
Forum Newbie
Posts: 17
Joined: Mon Jun 28, 2010 2:02 pm

Re: Using checkbox deleting the data from database

Post by eruna »

I don't see the rest of the form. You need a form tag and submit button.
The action of the form goes to a script the processes the data.
Post Reply