How Do You Do A CASCADE Delete In MySQL?
I'd like to delete a record and all its children records at one time. How do I do that?
Can you, in one SQL statement,
delete from table 1 where id = 3 delete from table 2 where id = 12 delete from table 3 where id = 12 ......
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Cascade Dropdown Or Conditional List
I would like to create a conditional cascade form. based on the selection, it can display or not display an input form for the user to enter an string of text. then at the bottom of the page (or when a user submit) connect all the sections including the input field all together (it's like a story maker?)
Mysql Delete
how would i do the following ? $query = mysql_query("DELETE notes, datestamp, abs_value, ID FROM absence_mgt WHERE datestamp='$date' AND ID='$vtc_login' ") or die(mysql_error()); im just getting "Unknown table 'notes' in MULTI DELETE" ?
Delete MySql Row By Date
Can someone help me with the following problem: I have a table that includes a column for "last application date", let's simply call it "date". Now the problem is how to automatically delete rows where the information in the "date" column has gone old, let's say by -86400 (1 day). Example: today's date is April 11th, which means that all rows with the info April 10th in the date column would get deleted.
MySQL - Delete Across Two Tables. OT
i cant find the MySQL newsgroup, however i am hoping to pick up on some expert advice from php/mysql gurus here. I'm having some trouble performing a delete across two tables. The tables i have are: questionnaires (id, name); questionnaire_questions (questionnaires_id, id, name, qf_type) The questionnaire_questions table contains a list of questions for a specific questionnaire (indicated by the questonnaires_id). I would like to remove a questionnaire, and when doing so all corresponding questionnaire_questions who have matching id's (questionnaires.id = questionnaire_questions.questionnaires_id). I have this statement, however it only works if a questionnaire has questions... however i would like it to delete even if no questions exist for that specific questionnaire. The SQL i am using is: delete questionnaires, questionnaire_questions FROM questionnaires, questionnaire_questions WHERE questionnaires.id = questionnaire_questions.questionnaires_id AND questionnaires.id = THE_QUESTIONAIRE_TO_DELETE_ID
DELETE Problem With MySQL
I've been learning using PHP and MySQL from the tutorial at freewebmasterhelp.com. Everything works fine, except deleting things. The script is invoked with a URL like this: http://www.example.org/test/delete_entry.php?id=35 And here's the script: <? include("dbinfo.inc.php"); $id = $_POST['id']; mysql_connect($server, $user, $password); $query = "DELETE FROM test1 WHERE id = '$id'"; @mysql_select_db($database) or die("Unable to select database."); mysql_query($query); mysql_close(); header("Location: entries.php"); ?> The dbinfo.inc.php file defines the variables $server, $database, $user and $password. The login part works.
Mysql Delete From A Form
i'm trying to find out how to get this to work. You type in a name of a record in the database and it removes it. In this case it's deleting the record that when you type in the name of the server it looks for it in the column "servername". You type in the servername and it will delete the whole record. Code:
MySQL MultiTable Delete...
I've been able to delete rows from one table successfully but what I want to try next is giving me some problems. I have a users 'id' which is unique. Heres what I want to-do. DELETE * FROM users WHERE id = 1 DELETE * FROM messages WHERE from = 1 DELETE * FROM comments WHERE user = 1 In each table there oginizaed a little different hense the id , from & user... but thats what I want to-do, without having to-do them all sepreatly, would like it to be efficent. the users ID will be passed along as the var 'id' any thoughts? So pretty much it takes the users id number and deletes them from each table.
Mysql Delete Record
when I run this code below it doesn't delete the record or display any error message $id = $_GET['id']; include("../dbconnect.php"); mysql_query("DELETE FROM promotions WHERE id='$id'") or die(mysql_error()); Such a simple thing to do but I don't no why it doesn't work
How To Delete Only Certain Text In A Mysql Row?
I have a table setup that has a column setup as friends and users can add friends to this column no problem. What I would like to know is how to delete only certain parts of the text of the row/cell where their friends are stored. The friends text is seperated by the following : " , " That is a space on either side and comma in the middle of the space. I know how to explode the results and put into an array to display the reuslts, but is there a way to delete only one of the friends if the text is as follows. , thomas , frank , irene , I think you can get the idea. Is it possible to do this or should I just update the whole cell without the array[$i] result being the friend?
PHP Unlink() & Mysql Delete
Im trying to delete a file, then delete the row in my table that holds the info for this file. I tried the code below and got this error: Parse error: parse error, unexpected T_STRING in /nfs/cust/4/97/13/731794/web/Admin/backup/PXS_DeleteBackup.php on line 34 Here is my code:
Mysql Row And File Delete
I have a database with the following colums, imageID, imageName, imageDesc, imageFile, imageHeight, imageWidth, imageThumb, imageThumbHeight, and imageThumb Width. I can easily delete a row from the mysql table, galImages, but I also want to delete two files from a directory. The file names are stored in the columns imageFile and imageThumb.
Php/mysql Insert, Update, Delete All-in-one
I have a check box form in an admin area, that links various related tables into one. These check box results are stored in an array, and then looped, there are in fact four groups of arrays, but the array length could become large (i.e. dozens - not hundreds) The issue I have is that from the one form multiple things need to occur. - If a box is checked and the record doesn't exist a new record needs to be inserted. - If a box is checked and the record does exist, it should be ignored (as it already exists). - If the box is unchecked and the record exists, it should be deleted. - If the box is unchecked and the record doesn't exist it should be ignored (the record doesn't exists). I'm looking for the logic and process (rather than being hand fed code ) Can this be done with 1 (or more likely 2) sql statements. Or do I have to loop thru the arrays, checking the existance and then applying a specific sql statement depending upon checked status and the records existance. Someone mentioned using IF() in the sql statement, but I am not familiar with that one.
Delete Row From Mysql Only Deletes The Contents?
mysql_query("DELETE FROM cart WHERE ItemId=$ItemId"); There is the code but the result in my databse is that the ID number changes from, lets say, 77 to 78 with 78's contents being empty. Therefore when I look at the results - the deleted ID77 is gone but now I have ID78 with no content! Does anyone know why and how do I make it stop?
MySQL DELETE: How To Get Page To Refresh?
I have a script that deletes records in a table. It works fine. However, it redirects the browser back to the page and the record stills shows there. Only after the page is manually refreshed does it disappear. I've used both header("Refresh...") and header("Location...") to accomplish the redriect, but no dice. The only thing that seems to work is if a unique URL is pushed into the address bar, which I do by appending md5(microtime()) to the end of the redirect URL.
Select & Delete Mysql Queries
i've try to insert and delete record at the same page, but it only can insert and can't delete the record. when i click submit button from the previous form, the record is insert into table B and delete from the table A. is the code correct? Code:
Delete Data From MySQL Database
I am new to PHP and MySQL but I have setup a MySQL database. I can view the information in an HTML table using PHP scripts and can delete an entry form the database table, but what i need to do is to be able to delete an entry by selecting a radio button next to the relevent information however when i try to add a form in the PHP script i get an error.
Delete Textfile List From MySQL Table
I have a list of email addresses that I need to delete from my database and they are in a textfile, one on each line like below... a@b.com c@d.com e@f.com etc. does anybody have a snippet of PHP code that I could use to accomplish such a task?
PHP File To Delete Multiple Talbes In MySQL
i installed PHP Nuke, didnt really like it. I think its much more then what I need. Great System, just think alot of it is useless for my needs. In any case i want to delete all the tables it created in my DB. Anyone got a script I can run to delete all tables that start with.
How Do I Delete Selected Rows From MySQL Table?
I am trying to figure out how to delete selected rows from a MySQL database table. The web site that I am working on has a page that will extract rows, using the "SELECT * FROM .. etc." statement from a database and output them in a table - like the one below (bottom part). I've got that part figured out. What I am trying to figure out is if the user puts a checkmark in one of the checkboxes (below) how would I write the PHP code to delete one or two of the rows from the MySQL table? PHP Code:
Delete From $var
Is it not possilbe to have a variable for the table name in a delete statement (mysql database). inside an if this button is hit statement I have: $sql = "delete from $type where id_num='$number'"; mysql_query($sql); echo "$sql"; when it echos $sql it doesnt have the $type var where the table name should be, it just leaves that blank.
Delete A Row
This should be simple enough but for some reason it's not working. The $name is a number which is being posted across when the user clicks submit. I want the PHP to then access the Database with this number and use it to delete the staff ID (which is a PK). With this code I get the error: Warning: ociparse(): supplied argument is not a valid OCI8-Connection resource in /homedir/ilex-s01/jmsuther/public_html/DeleteStaff.php on line 16 Warning: ociexecute(): supplied argument is not a valid OCI8-Statement resource in /homedir/ilex-s01/jmsuther/public_html/DeleteStaff.php on line 17 ; The code is: $name = $_POST["staffnodelete"]; IF ($staffnodelete=="" ) {print "You selected $name - for deletion ";} putenv("TNS_ADMIN=/u1/oracle/Products/shu10g/network/admin"); $con = OCILogon("username","password","10g"); $query = "DELETE FROM staff WHERE staffno = $name"; $query = $query_post [$name]; $stmt = ociparse($conn, $query); ociexecute ($stmt);
How To Delete Fields
I would delete with php, all record of a table mysql where the seven left chars of the field is equal to the data in input($seven_chars). I have used the the belowe istrucrion but it do not work.how can I do? mysql_query ("DELETE FROM my_table WHERE substr(myfield,0,7)=$seven_chars");
Delete A Line In PHP
What i want to do is to open a file read the file Select a particular line from the file and delete that line and close the file. How to do it in PHP.
Can't Delete Cookie
Right I am quite new to php but have managed to create a simple log in/log out thing with cookies. All was working fine and as expected until I added a new section of the site. The new section stores another cookie (latest message user has read) so that next time they visit the site it will highlight the 'new' messages. However since adding this I can no longer log out.
Can't Delete Cookie, Help Please~
Page1: <? setcookie("book_id", $book_id ); ?> Page2: <? setcookie ("book_id", $book_id, time() - 3600); ?> Can't delete cookie at once but reload page 2 two times how to delete $book_id cookie without reload?
Cookie Won't Delete
I'm trying to setup a simple user authenication for my site. I'm using cookies to pass the credentials between pages. But the function header() is giving me problems logging in and logging out. As you can see in the code below, I try to redirect the user to a page after setting or deleting the cookies. The scripts redirect okay, but the user never logs in and never logs out correctly. The scripts works correctly (logging in & logging out) only if I comment out the header() function. Here's my code for setting the cookie (login.php):
Delete File
I want to delete a file that is located on a server. The filename is in a Mysql database and now I have to put the line 'system("del c:apachehtdocsshopimg.gif");' somewhere in my code underneath. Any Idea how ? This line works already, but now the '.GIF' has to become a $file that equals the filename from the database...
Delete All Replicated Except One
I ran PHP codes that creating tables and inserting records to tables., But something happened, someone of them is inserted more than once. aa1345 | Ninsonoto aa1345 | Ninsonoto aa1348 | Ayumi Tohina aa1348 | Ayumi Tohina aa1348 | Ayumi Tohina There are thousands of records there. So I think i have to write a script that able to delete all the replicated except one.. e.g : Delete four of aa1348 records.
Delete New Lines
I would like to delete the new lines, I mean the, so Itried this: str_replace($row['facts_conten t'], " ", "") ; But the new lines are still there, how can I do?
Can't Delete From Table!
I'm not to familiar to php and sql. I have this assignment to read from database in a table and I HAVE TO be able to push a button causing one costumer to vanish. something to do with id = $id... can anyone help me... and help me fast! This is my code:
What Is The Best Way To Delete File ...?
I have script that allows a user to upload a txt file for processing, filtering, to save bandwidth,instead of user reuploading the file everytime he/she does a new process on the same file, i save the file to the server, and process from that file. What I want to be able to do is, when the user uploads a new file, or leaves the site, this temp file is automatically deleted (saves disk space).
Delete From Many Tables
I am trying to delete rows from a mySQL DB that consists of multiple tables. I am trying to use a function PHP Code:
Delete Records
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']??
SQL Insert And Delete?
Anyone know if there's a way to call a query but remove whatever you grabbed from the database, or would I have to do a query to retrieve what i needed, then follow it up with a delete on the same query results?
Delete An Object ?
I use OOP with PHP4 and i don't understand something. I have 2 classes VISIT & PLANNING like that: class clVISIT { var $when; var $where; //constructor function clVISIT($_when,$_where) { $this->when = $_when; $this->where = $_where; } } class clPLANNING { var $who; var $visit = array(); //constructor function ClPLANNING($_who) { $this->who = $_who; for ($i=0;$i<10;$i++) { $visit = new clVISIT("foo".$i , "foobar".$i ) ; } } } Ok, in the last constructor, we can see that i create new clVISIT object. My question is: how can i delete some of them in the same constructor ? is there a word like "new" but to delete ?
Delete Script
PHP and MySQL and I'm having some problems getting this script to work. I can't get this to work and I don't understand why. I don't get an error or anything, it almost seems like the page refreshes. I went to the phpmyadmin and the row is still in the database. The $_GET parts work perfectly in another script and the SQL statement works when I insert hard values in it. Any thoughts would be greatly appreciated. Thanks in advance. <form method="POST" action="<?php print $_SERVER['PHP_SELF']; ?>"> <table> <tr><td colspan="2" align="center">Yes <?php input_radiocheck('radio','yes_no', $defaults, 'yes'); ?No <?php input_radiocheck('radio','yes_no', $defaults, 'no'); ?> </td></tr> <tr><td colspan="2" align="center"><?php input_submit('save','Add'); ?> </td></tr> </table> <input type="hidden" name="_submit_check" value="1"/> </form> <?php function process_form() { // Access the global variable $db inside this function global $db; $isbn = $_GET['isbn']; $artist_name = $_GET['artist_name']; $album_title = $_GET['album_title']; if ($_POST['yes_no'] == 'yes') { $delete_sql = "DELETE FROM lounge WHERE isbn = $isbn AND artist_name = '$artist_name' AND album_title = '$album_title'"; // Delete the record $db->query($delete_sql); print "The record was deleted"; } else { print "The record was not deleted"; } } ?>
Delete File();
I was wondering if php4 has a built in function that could delete a file. In my case I need my php to delete a picture. (jpg, gif) Does php4 have the ability to delete an exsiting file? Something like this?? delete_image("../images/somePic.jpg");
Delete Not Working
Can someone tell me why this delete isn't working: $strSQL = "DELETE FROM tblMine"; $rsEmpty = mysql_query($strSQL); I just can't get it work.
Delete File
Is there any way to use PHP to delete an external file?
DELETE Syntax
i have this code: $sql = "DELETE FROM $table_name WHERE subscribeid = $userid"; it works fine, but i also want to check some other variables when i delete. i want to use: subscribemail = $usermail subscribecode = $usercode i tried: $sql = "DELETE FROM $table_name WHERE subscribeid = $userid AND subscribemail = $usermail AND subscribecode = $usercode"; but it doesnt work. i looked in the manual but couldnt see what i was doing wrong, anyone got any ideas?
Delete From Database
I have code that does not delete from a database. The same code (cut an paste in the same file, but different function and having a different query) works. So, of course, I tested the query interactively. I echoed the query and did a cut and paste when interactively connect to the database. That one worked so it isn't the query since interactively it is seeing exactly the same thing as the code produces. Here is the code: function deleteCatalog($catalog) { $query = "DELETE FROM CatalogNames WHERE sCatalogID='" . $catalog . "'"; mssql_select_db($database_Login, $_SESSION['Login']); $result = mssql_query($query, $Login); ... } The $query echos: DELETE FROM CatalogNames WHERE sCatalogID='CMP' As an example of code that works (in the same file) function addToCatalog($cat_id, $cat_name) { $query = "INSERT INTO CatalogNames (sCatalogID, sCatalogName) " . "VALUES ('" . $cat_id . "', '" . $cat_name . "')"; mssql_select_db($database_Login, $_SESSION['Login']); $result = mssql_query($query, $_SESSION['Login']); ... } The second and third lines are identical (cut and pasted) as in other places in the same code. In fact, it is only in this file that I do all the database work. Every other function works. This is the only delete, however.
Delete From Array
let's say I have an array $letters(a,b,c,d,e,f) is there a function that will remove 'd' from the middle. I'm looking for something like array_delete($letters,'d');
Add/Delete Items
I have the following code, that displays a message whether a users shopping cart contains items or not. How do I add/delete items from the shopping cart, upon the appropriate product link being clicked? If a items is already in the cart, how do I display a message notifying the user? Code:
Delete Record
Im some having trouble with deleting a record, surely it isnt that hard, dont know what im doing wrong. this is the error i am gettin: 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 id=1' at line 1Here is my delete code:
|