473,385 Members | 1,730 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

selected checkbox value not deleted

hi,
i writing the code for selectd check box value deleted.but the code not working


<?php
include("conn.php");
$sel= mysql_select_db("sangoma");
//include("function.php");

?>
<form method='post' action='test3.php' name='agentdisp'>
<?php
$sql = "Select * from test;";
$result=mysql_query($sql) or die ("<br> Could not Retrieve Data <br>");
$num_rows=mysql_num_rows($result);
While ($row =mysql_fetch_array($result))
{
$currentCom_id = $row['com_id'];
echo $currentCom_id;
?>
<input name="checkbox[]" type="checkbox" id="checkbox[]" value="<? echo $row['com_id']; ?>">
<?php
}
?>
<input name="delete" type="submit" id="delete" value="Delete">





<?
// Check if delete button active, start this
if($_POST['delete'] == 'Delete')
{
for($i=0;$i<$count;$i++)
{
$del_id = $_POST['checkbox'][$i];
$sql = "DELETE FROM test WHERE com_id='$del_id'";
$result = mysql_query($sql);
}

}

mysql_close();

?>
</form>


pls reply me...
Feb 16 '08 #1
2 1951
hsriat
1,654 Expert 1GB
hi,
i writing the code for selectd check box value deleted.but the code not working


<?php
include("conn.php");
$sel= mysql_select_db("sangoma");
//include("function.php");

?>
<form method='post' action='test3.php' name='agentdisp'>
<?php
$sql = "Select * from test;";
$result=mysql_query($sql) or die ("<br> Could not Retrieve Data <br>");
$num_rows=mysql_num_rows($result);
While ($row =mysql_fetch_array($result))
{
$currentCom_id = $row['com_id'];
echo $currentCom_id;
?>
<input name="checkbox[]" type="checkbox" id="checkbox[]" value="<? echo $row['com_id']; ?>">
<?php
}
?>
<input name="delete" type="submit" id="delete" value="Delete">





<?
// Check if delete button active, start this
if($_POST['delete'] == 'Delete')
{
for($i=0;$i<$count;$i++)
{
$del_id = $_POST['checkbox'][$i];
$sql = "DELETE FROM test WHERE com_id='$del_id'";
$result = mysql_query($sql);
}

}

mysql_close();

?>
</form>


pls reply me...
what is $count?
[PHP]for($i=0; $i<count($_POST['checkbox']); $i++)
{
if (isset($_POST['checkbox'][$i])) $del_id = $_POST['checkbox'][$i];
$result = mysql_query("DELETE FROM `test` WHERE `com_id`='".$del_id."'");
}
[/PHP]

And please format your message well before posting.
Feb 16 '08 #2
ronverdonk
4,258 Expert 4TB
This is the fourth time (3 via forum, 1 via PM) that you are requested to follow some simple Posting Guidelines and enclose any code within the appropriate code tags!

If you have no intention or do not wish to follow some simple forum rules, I will block your next post!!

moderator
Feb 16 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: M | last post by:
Hello, I would like to get a value for a non selected checkbox in a form. Imagine my form contains : <input type='checkbox' name='t' value='1'> <input type='checkbox' name='t' value='1'> ...
11
by: =?Utf-8?B?UGFyYWcgR2Fpa3dhZA==?= | last post by:
Hi All, I have a large recordset to be displayed on a ASP 3.0 page. I am using recordset paging for this. For the next and previous link i am passing href as <a href=<Page URl>?page=<%=...
1
by: ahilar12 | last post by:
Hi all, I am new to php,my question is that in this following code i am retrieving many rows from the database which is working good.i want to delete a particular row(s) which is checked(checkbox)...
21
by: mukeshrasm | last post by:
Hi I am deleting records from database using checkbox. means only that record will be deleted from database which are selected in checkbox. and before deleting record I am displaying a message...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.