Delete Multiple Records In The Same Database Querie?
I have some code that deletes records from the database, in a loop. However its prety inificient as it makes a seperate database call in every loop whcih is slow. PHP Code:
for ($i=0; $i<count($idarray); $i++)
db_query("delete from clicks where id='$idarray[$i]'");
Is their a more efficient way of doing that? It is posible to delete multiple records in the same database querie?
View Complete Forum Thread with Replies
Related Forum Messages:
DELETE RECORDS - Database Adding New Records
iv got the database adding new records, and now I want it to display all of the records that are there buy name and id number, then i want u to be able to type in the id number of the customer u wish to delete and it shoudl delete it, sounds good buts its not actually deleting the record. it says it does, but its not doing it. Code:
View Replies !
Multiple Delete From A List Of Records
If I have a list of records from a database on the screen, each with a check box beside them, how would I delete all the records that have been ticked? I assume I would use a variable similar to checked[], but not sure what syntax I would use to remove them from the database? Would I loop round each record comparing the checked[] value and it it's set, delete the record?
View Replies !
Display Records From A MYSQL Database On Multiple Pages.
I am trying to display records from a MYSQL database on multiple pages. I get the following error when I attempt to display the results mysql_fetch_array(): supplied argument is not a valid MYSQL result in c:intentpubwwwrootprogeneefsires1.php on line 238 The code is shown below. I am including a file called class.pager.php for page numbers (author: Tsigo) and this part works fine. /* Now we use the LIMIT clause to grab a range of rows */ $result = mysql_query("SELECT sireid, sirename, sirethumbpic, comment_1,comment_2,comment_3 FROM beef".$start.", ".$limit);
View Replies !
Records Won't Delete
mysql_query("DELETE FROM guestbook WHERE id = '$recnum'"); It works fine on my local server but it doesn't delete records on the remote server. any ideas?
View Replies !
DELETE Records
I am going to write a php script to delete some records based on values supplies by the user. I was just wondering if the query is correct but there are no records to delete for example if this query was executed but there was no testId 7, would an error occur or would the query be performed but just not delete any records? PHP Code: $testId = 7; $q="$q="DELETEÂ Â FROM test WHERE testId = $testId"; mysql_query($q, $link_id)or die(mysql_error());
View Replies !
Wants To Delete Old Records
I want to delete records that are more than 7 days old($keeptime). I am new to this and can't figure out the correct code. The table is called 'x4tables' and the field 'tdate' is a timestamp. I have used: Code:
View Replies !
Delete Records Since A Week
I've been trying to delete records since a week and i'm not able to do it. Before with this script, i was doing so many things at a time and i was confused.But, now, i just displaying the records from a table N trying to delete them.Would somebody pls guide me. I just wanna set the delete flag(i.e, i want to set the RBS_DELETE column to Y or something) when i check a check box to delete it. I've some 5 records displaying on my form and i want to check 3 of them and when i check them and hit submit, i want the RBS_DELETE column to have some value. PHP Code:
View Replies !
Delete Records From A Table
I have a table its called queue. It has a field called id. I want to delete all records in the table apart from the ones with id equals to 74 or 75 or 87. How do i do that?
View Replies !
Forms To Delete Records
I am trying to make a PHP script that displays all of the records from a database, then allows a user to edit or delete the records via a form. I need a checkbox beside the names and a text field with a number beside each name. Is there a way to make it delete all names with a check beside them and update all number that have been changed when the user clicks submit?
View Replies !
Delete Records From Table 1
I have a script that doesn't delete records from one database when it should, and now I have to do this myself because database is big and causes problems on the server. What I have is: TABLE 1, field auction TABLE 2, field id so I would like to delete all records from TABLE 1 where the value of the field auction doesn't match the value of the field id in TABLE 2. Can someone help me on this, please? I need to get this database cleaned.
View Replies !
Delete Specific Records
On clients machine, currently to delete on trainee record it runs 10 queries to delete records from 10 tables. At the time of running all queries, server shows (104) Connection reset by peer. An error condition occurred while reading data from the network. I think it because of running 10 queries at a same time. Is there any possibility that through one line of query we can delete record from 10 tables. I've tried following query DELETE FROM table1, table2, table3, table4, table5, table6, table7, table8, table9, table10 WHERE empID = 11; But it gives ' error in query.
View Replies !
Delete All Records Starting In R
PHP Code: $result2 = mysql_query ("DELETE FROM r_CompTables WHERE CompID = R??") or die("DELETE error: ".mysql_error()); I have this code but I want it to delete anything start in R. R will be followed with a number so it could be R5 or R91.
View Replies !
Delete Fixed Number Of Records
i have a table with one field. this field saves times as records. i want to there are 40 recoreds always. in other mean when inserts 41'st record then 1'st record be delete how to delete fixed number of records at a time of first of my records asc (like select). in other mean i want to like: delete from table order by time asc limit 0,1
View Replies !
Delete Selected Records From Table.
Can anyone see why this connection doesn't work? It's suppose to delete selected records from my table. <?php if (isset($_POST['delete'])) // && isset($_POST['delcus'])) { foreach ($_POST['delcus'] as $val) { echo "$val"; $conn= mysql_connect( "localhost", "user", "password" ); $sql = mysql_select_db( "snow" ); $del = mysql_query("DELETE * FROM request WHERE qid =" .$val); //$rows = mysql_num_rows($del); $rs = mysql_query($conn, $sql, $del); if($rs) .........................
View Replies !
Do A DELETE Statement To Remove Any Records That Don`t Match.
I`m just trying to figure out the best method to delete my records and wondered if it was possible to do a DELETE statement to remove any records that don`t match. Here is my code so far: $Query="select blah its huge:-)"; $RESULT=mysql_query($Query); $my_rows=mysql_num_rows($RESULT); for ($a=0; $a<$my_rows; $a++){ mysql_data_seek($RESULT, $a); $Array = mysql_fetch_array($RESULT); printf("%s<BR>", $Array['Email']);} My Query returns Matched Records, what I would like to achieve is deletion of the records that didn`t match, would it be possible to do that under the printf statement. So delete all the records in the table that don`t match up to $Array['Email']??
View Replies !
Delete Option From My View Records Page
I have a list of things I need to do with my database - but this is my next hurdle - the delete query within my view records page. I want to be able to click on a button or link to delete a record in a table. I was envisaging that each record would have a delete button or link next to it and clicking that would remove it. Here is the script I have created to view "Devices": PHP Code:
View Replies !
Auto Delete The Old Records But What If Server Clock Was Set Up Wrong In Maintenance?
I want auto delete any events that the event date is at least 1 day older than current date. No problem for the php programming. get the current data (server clock), check the events date and delete the old records. My problem is that for some very rare cases. Say if for extrem cases I have 1000 new events saved in database. But somehow, I or the the hosting company do the server maintenance, and reset the time clock of the server, in case in the maintenace, the server time clock was set up wrong say 2005, was set up as 2006. Code:
View Replies !
Difficult Limit Querie
I have two tables: Table 1: Courses CourseID Other irrelevant details.... Table 2: Lectures LectureID DateOfLecture CourseID The relationship: The course can have MANY lectures on different Dates. What I am trying to create is a MySQL querie that can list all of the courses along with the first lecture date for each course. I have considered many angles of attack on this one, it must be simple and must be done a lot can anyone give me any hints as how to do it?
View Replies !
Multiple Records To One
I have a database which comprises of a routes system.. some basic fields like ID | Routenum | Departure | Destinations | Deptime | Arrtime | Comments However, I have multiple routes where the Departure and Destination are the same, only the times are different. How could I make it so that only one appears on the routes list, instead of having about 5 similar entries?
View Replies !
Multiple Records And DW
I have a table in mysql with this fields id equipo puntos PJ PG PE PP I need a php script that show all the records in a way I can update all the data via ony one form. I read the topics post about this tread but still can't figure it out.
View Replies !
DELETE MULTIPLE ROWS
with the code below i delete 1 row even if several rows are selected, what should i do to be able to delete as much rows as much i select at once. Code:
View Replies !
Want To DELETE Row FROM Multiple Tables
I'm looking to delete a single row from multiple tables where they all share a common column name, primaryKey, and a common value - $POST_[primaryKey]. Here is the code: $query="DELETE FROM assetinfo, emplhistory, income, newuser, preliminfo, primarydata, reoinfo, residencehistory WHERE primaryKey='$_POST[primaryKey]'"; $result=mysqli_query($connection, $query) or die (mysqli_error($connection). " <br> Could't run DB Query to Delete Borrower"); And here is the error msg I'm getting: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE primaryKey='jarreola2'' at line 1 Could't run DB Query to Delete Borrower Is my query valid? Any other ideas on how to delete a row from multiple tables?
View Replies !
Multiple Table Delete
I have 3 tables that all have b_id in them. Blog table has b_id, title,author,body,date then I have a tags table that has t_id,name,b_id_blog and a comments table that has c_id,c_body,c_name,c_email,c_url,b_id_blog. My question how can I remove all data from the 3 tables based off the b_id?
View Replies !
Updating Multiple Records
I'll try and explain my problem!! Database table : Book Table : BookWords Fields : BookWordID Word Description I want to show : The word is $word add your description $description using th code below: [PHP]$db = mysql_connect("localhost", "root",""); mysql_select_db("Books",$db); $result=mysql_query("select * from Bookwords",$db); while ($rec=mysql_fetch_array($result)){ $wordid = $rec["BookWordid"]; $description = $rec["description"]; echo "$wordid: <input type=text name=quantity[$description]><br> "; } This is ok so far. Now i want the user to be able to add the description from the form and have the db automatically updated. I've tried the different methods I've found on this forum and I cant get anything to work!!!
View Replies !
UPDATE Multiple Records?
Is there a way to update multiple records with just one query, while all of the rows being updated are sent to the query as variables from different input fields? For example, if I had 5 different text fields, would there be a way to write one query that would update 5 separate records according to the respective input fields? All of the records that need to be updated would have a User ID row in common, so I could use UPDATE tablename SET qty='$newqty' WHERE user_id='$user_id' AND item='$item' But I'm thinking I would have to write 5 different queries, one for each text field i.e. ... SET qty='$newqty1' ... AND item='$item1' ... SET qty='$newqty2' ... AND item='$item2' ... SET qty='$newqty3' ... AND item='$item3' and so forth.
View Replies !
Editing Multiple Records....
Im trying to make it so that I can sort fo like edit all teh records in a table from one page, and im thinking have it like this: Field 1.........Field2......Field3.. Record1..................................Button to edit the info in this record Record2..................................Button to edit the info in this record Record3..................................Button to edit the info in this record Record4..................................Button to edit the info in this record
View Replies !
Multiple Records Into One Line
I wish to create a table with columns consisting of member name, member e-mail and a column that contains multiple records associated with a single member name: | Member name | Member e-mail | Records associated with member | _____________________________________________________ | member's name | e-mail address | record 1, record 2, record 3 etc. | Each record (those to be displayed in the column 'record associated with member' in the table has a member id linked to it, the member's name and e-mail are in another table also with the member id. The join between the two mysql tables would be through the member id attribute. Is there any possible way to put together a script for such a setup?
View Replies !
Insert Multiple Records
am trying to create a 'related articles' selection page. The administrator, after creating an article, can select older articles to include on the final displayed page. As the number of older articles increases, so will the number of possible relataed articles, so i am making a dynamic checkbox as the selection. This is all covered in Dreamweavers features, but, what i then need to be able to do is create a new record in the 'related_articles' table for each article selected when the form is submitted. I found this post below, which is more or less exactly what i want to do, i just wasn't sure that this was php code, looks like asp. Would someone be kind enough to show me how to change it to php code, or even write the code for me?
View Replies !
Multiple Records Update
I had set up a table like this. Id Name Win Draw Lost Points I need a page from where I can update all records at the same time. I can update one by one, can show the data, etc etc, but have no idea on how to update or delete multiple records via one single file.
View Replies !
Adding Multiple Records
i have mysql database table named 'table' it has fields : id (auto increment) , name , message , category , views currently i have php script that only adds one record at a time.now i want to add 10 records at a time.
View Replies !
Select Multiple Records
I have an application that uses mysql database. Several records are retrived from the database. To enable users to select multiple records, I've used checkboxes by the side of each record. However, the checkbox does not retrieve their value from the database, neither do they update the database. I just thought that by setting the value of the checkbox, I could determine the selected checkboxes and insert the corresponding records into the database. The selected records whose checboxes have been set are then inserted into another table. Or updated as I may also need to update some. My problem,however, is how to determine the selected records and then do multiple inserts into the database table?
View Replies !
Multiple Mysql Records
I am trying to develop a form which has the user inputing data in a columnar format. Each column has multiple fields (one for each row) there are 12 columns, I was able to submit to MySql database the first column fields. All subsequent columns would be the same field inputs but the values could be different. I need each column to be submitted to the database as a seperate record by using only one form submit.
View Replies !
Update Multiple Records
a table that contains a list of bidders (a live auction house, not an online auction), the lots they won at the auction, and the total cost of each lot, after they have paid i have the current php scripting displaying their credit card transaction code, etc. On the script to locate them for checkout it search for all the fields where the 'Bidder Number' equals their bidder number. basicly for each item they purchase one new row is inserted, it contains the ID (the primary key), the bidder number, the lot number, and the total for that lot. So if they purchase 5 items there are 5 different rows that contain that info. The checkout script locates every field where they are the bidder. What I need to do now is after their payment is completed I can submit the data via a form and it will change the column 'paid' to yes, and the column 'auth' to their authorization code from the credit card transaction. How would I do this? the query i use now to get a loop of all their lots and insert them into the credit card processing for is as follows. + $sql = "SELECT * FROM checkout WHERE bidnum=$bidder AND paid='no'";
View Replies !
Multiple Delete Checkbox Problem
I have a list of contacts that were sent from the contact page to my admin page. Now I want to be able to delete all the emails that I want with a checkbox system. I have asked around how to do this and found methods on how to do this but for some reason it doesnt work. So I use and array name in my checkbox name and the post id in my value field. Then I run a foreach loop and delete the results from my sql. For some reason my checkbox name is not being set as an array and I can't figure out why. Code:
View Replies !
Update Multiple Records Simultanously.
As my subject tells, my problem is to update multiple records simultanously. The post form in html contains in some cases the possibility to update, say, 4 email addresses (all with the field name "email"). How to process the input for such an update query? Yet, I numerated the email field names simply by stitching the counter in the loop on the field name (while generating the html form). Is this a good way to do it? And how to process the update?
View Replies !
Linking Multiple Records From Another Table
I'm not sure I'm even thinking about this the right way, but here goes: I have a table of users. Each one of these users may be associated with none, one, or many records in another table I call a todo table. table user = 'id', 'name', 'bla bla bla','todo_list' table todo = 'id','title','other info' Suppose user 'id=1253' has on his todo list items 756,241, and 672. I create a string 756,241,672 and store that string in the user's todo_list field. Then when I want to display the todo items I get the string with a query, bust it up into an array, iterate the array and query the todo table. I have a gut feeling I'm making it way more complicated than need be. But I can't think of any other way to do it
View Replies !
Update Multiple Records From One Page
Recently, I had a request to create a page in our database web interface where we can update multiple customer records from one page. Here's the flow of what we want to do: 1. Search for a customer by name. 2. Bring up a list of the matching customers and the data that is to be changed in text boxes in a table - one customer per row with 6 fields for each that can be modified (6 text boxes). 3. People can update the appropriate fields and click submit button. (** this is done to this point **) We may be returning as many as 250 records per search, so efficiency would be pretty important. I am not sure where to go from here. I would guess I should build and array of keys and values from the HTTP_POST_VARS that are submitted and then loop through them to UPDATE the database to the new values. I don't know how to do this, though.
View Replies !
Multiple Records Where One Field Matches
I need all of the records where the $topicID = 1,2,3,4 Here's what I have that's working off an array of checkboxes: $query = "SELECT * FROM expertise WHERE topicID = '$choice[0],$choice[1],$choice[2],$choice[3]'"; I know this is screwed up. The results are less than reliable. It appears to only pay attention to matches for $choice[0] and then lists results that don't match the other choices selected.
View Replies !
Multiple Row Insert - Variable Records
I am wanting to insert into a table multiple rows automatically. I relaise that you can use "VALUES ("string1", "string2"), ("string3", "string4")" to insert multiple rows, but I cannot specify the values I want to insert, and similarly the number of records to insert. Code:
View Replies !
Insert Multiple Records In Table
I want to use a form to insert multiple records into a table. I have an book club where a person would rank a book (3 to 1) next to a particular book read for a particular month. 3 being the most favorite book read that month and 1 being least favorite. Below is the table the records would be inserted into. Key----Month--------Reader---------Rank-------Book 1-------January-------Jim--------------3----------Bible 2-------January---------Jim-------------2----------Koran 3-------January---------Jim-------------1-----------Torah How can I have a form where the reader sees only (and fills in) the rank and book text fields, and the Key, Month, and Reader fields are filled in behind the scenes with the default info when the form is submitted .
View Replies !
|