Delete multiple records
I need to delete muliple records from a table called
leag_leagues. I made a form on the first page and set the value of
the checkboc to the value of my id for my table. I then want to
pass it to the delete page where it deletes the record and
redirects to the delete record complete page. I am using PHP and
mySQL.
Any help would be appriciated.
here is my code on the start page:
<?php require_once('../Connections/test.php'); ?>
<?php
mysql_select_db($database_test, $test);
$query_leag_leagues = "SELECT * FROM leag_leagues ORDER BY
leag_name ASC";
$leag_leagues = mysql_query($query_leag_leagues, $test) or
die(mysql_error());
$row_leag_leagues = mysql_fetch_assoc($leag_leagues);
$totalRows_leag_leagues = mysql_num_rows($leag_leagues);
//prevents caching
header("Expires: Sat, 01 Jan 2000 00:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: post-check=0, pre-check=0",false);
session_cache_limiter();
session_start();
//this should the the absolute path to the config.php file
//(ie /home/website/yourdomain/login/config.php or
//the location in relationship to the page being protected -
ie ../login/config.php )
require('../config.php');
//this should the the absolute path to the functions.php file
- see the instrcutions for config.php above
require('../functions.php');
//this is group name or username of the group or person that
you wish to allow access to
// - please be advise that the Administrators Groups has
access to all pages.
if (allow_access(admin) != "yes")
include ('../no_access.html');
exit;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
Transitional//EN" "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="
http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1" />
<title>Slippery Rock Lanes Admin</title>
<style type="text/css">
<!--
body,td,th {
color: #000000;
body {
background-color: #CCCCCC;
a:link {
color: #999999;
text-decoration: none;
a:visited {
text-decoration: none;
color: #999999;
a:hover {
text-decoration: underline;
color: #666666;
a:active {
text-decoration: none;
color: #CCCCCC;
.style1 {color: #CCCCCC}
-->
</style></head>
<body>
<table width="100%" border="0" bgcolor="#FFFFFF">
<tr>
<td width="16%" rowspan="4" valign="top"><img
src="../assets/admin_pin.png" width="125" height="570"
/></td>
<td width="84%" bgcolor="#FFFFFF"><img
src="../assets/admin_logo.png" width="541" height="56"
/></td>
</tr>
<tr>
<td bgcolor="#FFFFFF"> <a
href="adminhome.php">Home</a> - <a
href="adminuser.php">Users</a> - <a
href="adminleague.php">Leagues</a> - <a
href="calendarevents.php">Calendar</a> - <a
href="allys.php">Allys</a> - <a
href="coupons.php">Coupons</a> - <a
href="hours.php">Hours</a> - <a
href="honorroll.php">Honor Roll</a> - <a
href="email.php">Email</a> - <a
href="stats.php">Stats</a> - <a
href="../home.php">View Site </a></td>
</tr>
<tr>
<td height="470" valign="top"
bgcolor="#FFFFFF"><form id="deleterecords"
name="deleterecords" method="post"
action="deleteleagueconfirm.php">
<table width="700" border="1">
<tr>
<td width="24"><div
align="center"></div></td>
<td width="49"><div
align="center">ID</div></td>
<td width="300"><div
align="center">Name</div></td>
<td width="153"><div align="center">Start Date
</div></td>
<td width="152"><div align="center">End Date
</div></td>
</tr>
<?php do { ?>
<tr>
<td><div align="center">
<input name="id" type="checkbox" id="id[]"
value="<?php echo $row_leag_leagues['leag_id']; ?>" />
</div></td>
<td><?php echo $row_leag_leagues['leag_id'];
?></td>
<td><?php echo $row_leag_leagues['leag_name'];
?></td>
<td><?php echo $row_leag_leagues['leag_startdate'];
?></td>
<td><?php echo $row_leag_leagues['leag_enddate'];
?></td>
</tr>
<?php } while ($row_leag_leagues =
mysql_fetch_assoc($leag_leagues)); ?>
<tr>
<td colspan="5"><div align="right">
<input type="submit" name="Submit" value="Delete Records"
/>
</div></td>
</tr>
</table>
</form> <p></p></td>
</tr>
<tr>
<td valign="top" bgcolor="#FFFFFF"><div
align="right" class="style1">This Web Site Is Powered By Myth
Tech Administration Technologies </div></td>
</tr>
</table>
</body>
</html>
<?php
mysql_free_result($leag_leagues);
?>
And here is my code for the delete page:
<?php require("../config.php") ?>
<?php
$con = mysql_connect("localhost",$username,$password);
if (!$con)
die('Could not connect: ' . mysql_error());
mysql_select_db($db_name, $con);
if(isset($_POST["id"])) {
$delete = implode(",",$_POST["id"]);
$query = sprintf("DELETE FROM leag_leagues WHERE leag_id IN
(%s)",$delete);
mysql_query($query);
?>
Similar Messages
-
How to Delete Multiple Records using selectbox in jsf
Hi!
My Senario is I want to delete multiple records using checkbox. After selecting multiple records when i click the delete button the selected
rows shuld be deleted.if am doing like this but the edit ,delete for each row functionality is not working.
<h:selectBooleanCheckbox id ="bcb" value="#{item.empno}">
</h:selectBooleanCheckbox>
But other functionality is not wokring.
Can any one plz tell how to select the multiple records and how to send the id to the serverside.
I want code code for jsp and as well as backingBean how to accaess .
Any Reply shuld be apreciatedYou may find this article useful as well: http://balusc.blogspot.com/2006/06/using-datatables.html
Check the chapter "Select multiple rows" for two generic ways to select multiple rows in a datatable. -
Deleting multiple records via html checbkoxes?
I'm trying to delete multiple records in a table based on the
selection of checkboxes.
I have an html form with 4 checkboxes. If a user checks any
box, I want to delete the associated records. and if they ucnheck
something I want to insert multiple records. This form does not
hold the primary keys but other unique parameters. Here is my sql
statement.> and that keyword is not mentioned in the DELETE
statement chapter.
IN is not specific to DELETE statements. It can also be used
with SELECT or UPDATE statements. It is a way of specifying
multiple values in a single statement, instead of using multiple OR
statements:
http://www.w3schools.com/sql/sql_in.asp
Since you are using cfqueryparam, you also need to use
list="true" (ie you are passing in a list of values, not just one)
<cfset listOfValues = "1,2,5,6,8">
WHERE ColumnName IN
<cfqueryparam value="#listOfValues#" list="true"
cfsqltype="..."> -
Delete multiple record in tabular with check box.
Hello guys,
I need your suggestion..
I have master detail block. (INSTRUCTOR and SECTION)
At detail block, I add check box item (name: RB_SECTION_ID) with Database Item "No", and value when check :SECTION_ID (on the property).
I make a button DELETE. The trigger was DELETE from SECTION where section_id = :SECTION.RB_SECTION_ID and
instructor_id = :INTRUCTOR.INSTRUCTOR_ID;
but It not work.
How we delete multiple record by check multiple check box then click DELETE button..??
Regard.
Nia..You datablock in the form cannot automaticaly refresh the changes you make with the SQL statements.
For that you need to explicity call certain built-ins to refresh the data
execute_query(no_validate) --> fetches the available data for that session. Here you deleted some records, so those records will not be available until you do a rollback in the same session(i.e, you exit the form without saving). But until you save, those deleted records will be avaiable for the users in other sessions)
Also, your code works only because the records you deleted are all already saved ones.
So it will be a good practice to use built-in of form builder rather than DML stmt.s
Here you can do like this
begin
go_block('TRY_TABLE');
first_record;
loop
if :TRY_TABLE.CCKBOX = 'Y' THEN
delete_record;
END IF;
NEXT_RECORD;
EXIT WHEN :SYSTEM.LAST_RECORD = 'TRUE';
END LOOP;
END;
If your code is like above one, you can revert your deletion by simply giving a F7 (enter-query) and F8 (xecute query). -
hi all,
Can any tell tell me how to delete multiple records in table control of a screen
i have checked the multiple rows in table control attributed and assigned a name.I needhelp in writing code.
Thankshi,
As you have marked multiple fields in the table control your table control is mulple selection enabled.
<b>PROCESS AFTER INPUT.</b>
loop at IT_CONF.
field X_CONF-CHECK
module TC_CONF_mark on request.
endloop.
module TC_CONF_user_command.
MODULE USER_COMMAND_0102.
*this modifies the internal table with check field as X
module tc_conf_mark input.
data: g_tc_conf_wa2 like line of it_conf.
if tc_conf-line_sel_mode = 1.
clear g_tc_conf_wa2.
loop at it_conf into g_tc_conf_wa2
where check = 'X'.
g_tc_conf_wa2-check = ''.
modify it_conf
from g_tc_conf_wa2
transporting check.
endloop.
endif.
modify it_conf
from x_conf
index tc_conf-current_line
transporting check.
endmodule.
module tc_conf_user_command input.
* write code to handle table control scrolling /pageup/pagedown
endmodule
*Check the ok_code
module user_command_0102 input.
case ok_code.
when 'DEL'.
* Delete from internal table where check = X
endcase.
endmodule.
<b>PROCESS BEFORE OUTPUT.</b>
module TC_CONF_change_tc_attr.
loop at IT_CONF
into X_CONF
with control TC_CONF
cursor TC_CONF-current_line.
module TC_CONF_get_lines.
endloop.
module tc_conf_change_tc_attr output.
describe table it_conf lines tc_conf-lines.
endmodule.
module tc_conf_get_lines output.
g_tc_conf_lines = sy-loopc.
endmodule.
Thus you will delete the marked lines from the internal table in PAI and in PBO you can read the refreshed internal table without the table entries that are marked as deleted in the table control and display the same in the table control. This is another way.
Regards,
Richa -
Urgent: FORMS-III Deleting Multiple Records By Marking X
Deleting Multiple Records By Marking X
In Forms III, i need to delete multiple records by marking X (in non database Item)
i.e.
========================
D Empno Ename Deptno
========================
X 10001 ABC 10
10002 DEF 10
X 10003 GHI 20
X 10004 JKL 20
=======================
How To Do????????????
Rgds,
RashadCreate a button say lable "delete" in a block other than the block from where u want to delete records.
suppose the block's name is emp_blk
now create a WHEN-BUTTON-PRESS trigger for delete button and write the following code
begin
go_block('emp_blk');
first_record;
loop
if :emp_blk.d ='X' then
delete_record;
end if;
if :system.last_record='TRUE' then
exit;
end if;
next_record;
end loop;
end;
filnally commit on save. -
Delete Multiple Records from Item Master
Hi,
We received wrong master data which has been uploaded and two groups have to be deleted. All the items in those particular groups have also to be deleted. Can anyone suggest how to delete multiple records from Item Master?
Currently I am navigating through each Item and doing a Right Click + Remove. It is very painful given the huge number of records.
Regards
SudattHi Sudatt.....
I recommend you not to run any kind of delete or update SQL query as it harms DB.
You can create your own front end application with the help of any technical consultant which can be
achieved very easily. Else such problems create a big problem during upgradation to next version.......
Regards,
Rahul -
Need to delete multiple records at a time
Hi,
My requirement is to delete multiple records at a time, i am using JDV11g and read only ADF table and rowSelection="multiple".
i have taken command button and invoking the below method.
RowKeySet rowKeySet = (RowKeySet)this.t1.getSelectedRowKeys();
CollectionModel cm = (CollectionModel)this.t1.getValue();
System.out.println("RowKeySet is: "+ rowKeySet.getSize());
for (Object facesTreeRowKey : rowKeySet) {
cm.setRowKey(facesTreeRowKey);
JUCtrlHierNodeBinding rowData =
(JUCtrlHierNodeBinding)cm.getRowData();
System.out.println("RowData is : "+rowData.getAttribute("ParamValue7"));
rowData.getRow().remove();
Please do need fullHi,
I don't understand what you mean by "+Please do need full+" , so I am ignoring this part. Here's a link that shows you best practices
http://blogs.oracle.com/smuenchadf/examples/
See example 134.
Frank
ps.: I suggest you bookmark the link -
Please Help! Deleting multiple record by using checkbox selected
Hello everybody,
I am a new to JSP. I really don't know how to delete multiple record by using checkbox selected and pressing submit button.
For example, deleting webmailbox letters using checkbox selected and delete button. The mail we checked will delete from the inbox.
I like to use my user account deleting system of my project like above example.
How can I do in JSP? I will very please you if you share you knowledge and code for me.
If you have URL address, could you share me for reference?
Please help me...
With Thanks and Regards,
wtdahlTake a look at this thread, I thing it answers your question quite good:
http://forum.java.sun.com/thread.jsp?thread=516658&forum=45&message=2463505 -
Delete Multiple records in Table?
Hi ..
I need to perform delete operation in my table with multiple selection.
My coding is..
for(int i=wdContext.nodeDetails2().size()-1;i>=0;i--)
if(wdContext.nodeDetails2().isMultiSelected(i) || wdContext.nodeDetails2().getLeadSelection()==i)
wdContext.nodeDetails2().removeElement(wdContext.nodeDetails2().getDetails2ElementAt(i));
When i delete first record, It works fine and multiple selection also works fine.
But when i select last record(only one) to delete, Then All the records get deleted. ???? Why this happens???
Anybody help to solve this probelm..
Thnx in advance..
Regards,
GSHi Sathish,
Store the node size in a variable then try. To avoid problems with the index, the context is executed in reverse. Suppose in a table you have 10 rows and you are deleting row 2 the after deletion of row 2 row 3 will come to row 2,row 4 will come in row 3 in this way process will be continue up to last row.
Try this.
int n = wdContext.nodeDetails2().size();
int leadSelected = wdContext.nodeDetails2().getLeadSelection();
// loop backwards to avoid index troubles
for (int i = n - 1; i >= 0; --i) {
if (wdContext.nodeDetails2().isMultiSelected(i) || leadSelected == i) {
wdContext.nodeDetails2().removeElement(wdContext.nodeDetails2().getDetails2ElementAt(i));
Regards,
Mithu -
Delete multiple records with MDM WebService
Hi everyone!
I'm using an MDM Web Service with delete functionality. It identifies records to be deleted either by internal ID or by defined field value. The point is that i need this web service to delete all records with one specific value in specific field (lets say all the records with value "hidden" in field "VISIBILITY").
But when I try to map value "hidden" of the field "VISIBILITY" to the web service input in BPM it says in tracing that there are multiple fields with that value in the table (certainly there are) and that it can't process them. Cause it doesn't support multiple processing. Is there any way to do that?
Thanks in advance,
PeterHi Peter,
I guess you can do that if you first retrieve the internalIDs of the to be deleted records:
Do a search for the records with the field value.
Then you will receive the internalIds of them.
Then you can put these internalIds to the delete records webservice. Each in a new element of the record identification.
I hope this helps!
Best regards,
Stefan Brauneis -
Deleting MULTIPLE recorded programs
Ok so what happened?? At first I had to delete each program individually and then for a while all I had to do was click on the folder and it gave me the option to delete all of the recordings in that folder at once. Today I noticed it has gone back to making me delete each recording individually. WTW??? I like the option of deleting multiple recordings at once. :-( What happened and can i make it go back?
I just tested the folder delete and if you delete the folder it will put each show individualy into the deleted area. If you want to empty out the deleted area you would then need to delete each show from the folder individually.
-
Deleting multiple records using ibatis framework
The code i am using is
String deleteArray[ ] = request.getParameterValues("sel");
String selected= " " ;
if(deleteArray ! = null){
for(int i = 0; i < deleteArray.length ; i++){
selected += deleteArray [ i ];
if( i < deleteArray.length - 1){
selected += "," ;
I am using sqlMapClient of ibatis for connecting to database
sqlMapClient.delete("deleteMultipleRecords",selected);
In my xml file i use
<delete id="deleteMultipleRecords" parameterClass="java.lang.String">
delete from ADDRESS where id in (#value#)
</delete>
When i execute the above code , the delete query is not executing.Can anyone help me out.I dont think so u can delete multiple recods with a sing line of querey.
Why dont u use a for loop in DAO file and call the query with a single value .... -
Delete Multiple record in database block
hi to all,
i have one button. what i want if i press this button all the records that i selected from detail blocks will be deleted.
i used this code but i always received an error : FRM-40102: record must be entered or deleted first.
DECLARE
Num_Total_Records NUMBER;
Num_Loop_I NUMBER;
BEGIN
GO_BLOCK(<BLOCK_NAME>);
FIRST_RECORD;
LAST_RECORD;
Num_Total_Records := TO_NUMBER(NAME_IN('SYSTEM.CURSOR_RECORD'));
FIRST_RECORD;
FOR Num_Loop_I IN 1..Num_Total_Records LOOP
IF <CHECKBOX> = 1 THEN
if <condition> then
else
if <condition> then
else
end if
--condition is satisfied...deleted the selected record
delete_record;
commit;
end if
END IF;
NEXT_RECORD;
END LOOP;
<................................................>
END;baguhan,
by this if u have selected all records, some records will won;t delete.
because as poelger said, delete_record will already skip 1 record.
so instead of the code u gave , its beter to all else portion in the condition and in the else portion gave the next record.
this is the your code modified
DECLARE
Num_Total_Records NUMBER;
Num_Loop_I NUMBER;
BEGIN
GO_BLOCK(<BLOCK_NAME>);
FIRST_RECORD;
LAST_RECORD;
Num_Total_Records := TO_NUMBER(NAME_IN('SYSTEM.CURSOR_RECORD'));
FIRST_RECORD;
FOR Num_Loop_I IN 1..Num_Total_Records LOOP
IF <CHECKBOX> = 1 THEN
--condition is satisfied...deleted the selected record
delete_record;
commit;
else
NEXT_RECORD;
END IF;
END LOOP;
<................................................>
END;
Regards,
Manu -
MYSQL Error When Deleting multiple records
Folks,
I am finally converting my website from MS-Access to MySQL and until Monday I was having pretty good luck. However, I have come across a issue I cannot find any solution to and am wondering if one of you can assist.
When I try to delete a number of records using tgeh same commands that worked in Access, I get this error:
Microsoft OLE DB Provider for ODBC Drivers error '80040e21'
ODBC driver does not support the requested properties.
/New_Site/Trade/Trade_Signup_Edit_Update.asp, line 34
This is the code:
Set adoCon2 = Server.CreateObject("ADODB.Connection") adoCon2.Open "DRIVER={MySQL ODBC 3.51 Driver}; SERVER=MySQLB1.webcontrolcenter.com;" &_ "DATABASE=pinotdays; UID=pinotdays; PASSWORD=********; OPTION=3" Set rsTrade_List = Server.CreateObject("ADODB.Recordset") strSQL = "SELECT * FROM Trade_List WHERE Entity_Number = " & request.form("ID") rsTrade_List.CursorType = 2 rsTrade_List.LockType = 3 rsTrade_List.Open strSQL, adoCon2 Set rsTrade_Delete = Server.CreateObject("ADODB.Recordset") StrSql = "DELETE * FROM Trade_List Where Parent_Entity_Number=" & request.form("ID") & " AND Entity_Number <> " & request.form("ID") rsTrade_Delete.CursorType = 2 rsTrade_Delete.LockType = 3 rsTrade_Delete.Open strSQL, adoCon2
The error occurs on the final line listed. Being new to MySQL, I thought I would change teh driver to 5.1 but that brought me nowhere. I used "SELECT" in the string and tried to do rsTrade_Delete.Delete and that did not work. I tried to delete a single record by selecting a ID=1 and that did not work.
So, is there a trick to deleting records in MySQL?
Thanks for your help....
Regards,
SteveStrSql = "DELETE * FROM Trade_List Where Parent_Entity_Number=" &
request.form("ID") & " AND Entity_Number <> " &
request.form("ID")
The DELETE statement for MySQL deletes entire rows. No need to specify fields (or all fields with the asterisk). In fact, that should probably result in a syntax error.
StrSql = "DELETE FROM Trade_List Where Parent_Entity_Number=" & request.form("ID") & " AND Entity_Number <> " & request.form("ID")
Mark A. Boyd
Keep-On-Learnin' :-)
Maybe you are looking for
-
Please help if you can. We have oracle running on a Windows XP machine and another instance running on a Windows 2003 server machine. I get the same results when I try to run the export on either database. I connected to Oracle with SQLPlus and sent
-
Airplay from Apple TV to a speaker?
Is it possible to stream with airplay from Apple TV to an Airplay speaker (like Libratone Live)? I wanna have the same sound in every room. Playing from my Apple TV.
-
Can I install two FCP versions?
I installed FCP X but want to also run FCP studio 3 too... is this possible? Are there any issues I should know about?
-
Some error in setting table model to a JTable..kindly help..
hi all, i m pasting a code of a function in which i fetch data from the database n display it in a JTable pasted on a panel in a JFrame window. There is some problem with the table model which i m unable to correct. Kindly help.. public void showDeta
-
I changed my lock code on my iPod and I swore I typed it in corrcetly. I must have messed it up somewhere because now it's locked and I can't unlock it.