473,385 Members | 1,523 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.

delete multiple rows using check box in PHP

Hi ,
I am trying to figure out why my PHP code to delete multiple value by selecting the checkbox is not working.
Nov 15 '11 #1
5 2112
omerbutt
638 512MB
what is not working? where is the code ?, any errors received , paste them here
regards,
Omer Aslam
Nov 16 '11 #2
transfer the values of all checkboxes that are selected .
save all that in one array or one variable. if you saved them into one variable then explode its seperate
it's better to save those selected values in one array.
after that fire delete query using loop.
Nov 21 '11 #3
zorgi
431 Expert 256MB
@Bharat383

Looping and deleting is ok but probably not the best solution and is much slower than using pure SQL:

Expand|Select|Wrap|Line Numbers
  1. DELETE FROM `your_table` WHERE `id` IN (1,2,3,4)
If you have an array of row ids that you want to delete you could do something like this:

Expand|Select|Wrap|Line Numbers
  1. $ids = array(1, 2, 3, 4);
  2. $sql = "DELETE FROM `your_table` WHERE `id` IN (" . implode(',', $ids) . ")";
  3.  
No need for looping.
Nov 21 '11 #4
omerbutt
638 512MB
@ zorgi , yes you are very right looping will not be as faster as the pure SQL , and thats where it takes the edge, and is best fastest way to delete multiple records.
regards,
Omer Aslam
Nov 21 '11 #5
just my 2cent ... never forget to sanitize the input - you never know if the array of values you get from external input will be numbers all the way :-)
Nov 26 '11 #6

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

Similar topics

4
by: arizal | last post by:
Hi , I am trying to figure out why my PHP code to delete multiple value by selecting the checkbox is not working. My php code is listed as below <?php $sql = "Select * from list;";...
2
by: tanha kris | last post by:
CREATE OR REPLACE PROCEDURE gopal IS ReceivingSection VARCHAR2(20); DakId VARCHAR2(6); CURSOR c_Inward_DocumentDetails IS select DAK_Id, RECEIVING_SECTION into...
3
by: khairulfnd | last post by:
i want to select multiple rows using a checkbox in a gridview in which it will be posted in another gridview
3
madhoriya22
by: madhoriya22 | last post by:
I have solved the problem
2
by: prashanth023 | last post by:
Hi , Can any body please solve the problem I need a stored procedure that should take a number as input for number of records to insert. And it should take the row by row data and insert n...
3
by: =?Utf-8?B?S2F5xLFoYW4=?= | last post by:
In my project,i added datagridview to my form , i transfered my table to datagridview and added multiple rows and when i called dataadapther.update ,,result is ok. But when i tried it for the...
2
by: Michael | last post by:
It seems that a gridview allows us to delete only a single row at a time. How to extend this functionality to select multiple rows and delete all of the selected rows in a single stroke? just like...
3
by: nigelesquire | last post by:
Please help! I'm trying to clone and delete multiple rows with JavaScript. I need two delete buttons that work...! I only have one for now, but it's not working properly, the output count is...
0
by: bplthebest | last post by:
Hi I have have functionality like Selecting multiple rows (without using check boxes) in Grid view by Ctrl+click (IE) and shift+click(safari and Firefox). And edit the selected rows in a panel...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...
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...

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.