Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    PHP


SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





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

Related Forum Messages:
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?)

View Replies !
Mysql Delete - $query = Mysql_query("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" ?

View Replies !
Mysql DELETE
im a stuck again, could some one please tell me why this dosent work;

mysql_query("DELETE FROM messages WHERE from='$fromid', sento='$myid'");

View Replies !
Delete For MySQL
I'm an experienced java/C++/SQL programmer who hasnt used PHP. I'm looking for some generic database access pages for doing dds, edits, deletes, etc., hopefully with some error handling. I'd rather start with a basic shell of code, so I don't have to reinvent the wheel, and can just change connection string, database fields, etc.

View Replies !
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.

View Replies !
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

View Replies !
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.

View Replies !
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:

View Replies !
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.

View Replies !
How Do You Delete Records From Mysql
Could someone please show me how to delete records from mysql. Maybe even an example in a loop that deletes records based on a criteria.

View Replies !
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 

View Replies !
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?

View Replies !
How Do I Delete A Full Row In Mysql ?
how do i delete a full row in mysql ?

View Replies !
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:

View Replies !
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.

View Replies !
Delete MySQL Data
I am building a lunch ordering system for a company. The employees can login, order lunch, and the administrator can see what everyone ordered for lunch in the admin panel. The problem is that when the employees enter data, it stays in the database until they update it. If an employee is sick, their lunch order from the previous day is still in the database. Is there a way to clear those values they enter at a certain time in MySQL.

View Replies !
Mysql Query : Delete From *
When I use phpmyadmin, and run this sql query, it will tell me that it affected X amount of rows (lets say 10). However, when i run my script, it doesnt' tell me that. Code:

View Replies !
Delete Duplicates In MySQL
I have a database in MySql which has 2 fields. The 1st field is called id which is the primary key. The 2nd field is called full_add where there are some duplicates.

I would like to delete all the duplicates in the full_add field leaving only 1 record behind.

It does not matter if the corresponding primary key gets deleted as well because the primary key is not related to any other table or database. I prefer not to use temporary tables or create new tables because my webhost does not allocate much memory to me & my database is quite big.

View Replies !
How To Delete MySQL Database.
I've got three hostings with the GoDaddy hosting service. The hostings are supposed to provide only one MySQL database each. I've just recently noticed in the phpMyAdmin program that separate databases, each with the name "test," has appeared in two of the three hostings.

I don't know how they got there. I didn't put them there. I contacted GoDaddy's technical support. They said that the "test" databases automatically comes with the phpMyAdmin program. Of course, that's not right. Anyway they said that I could delete the extra database without damaging anything.

View Replies !
MYSQL/PHP Delete Script
Im having problems getting my delete script to work it comes back with: Delete Error: Unknown column 'EVANS' in 'where clause' so it is using the surname i input as the column name but why?

View Replies !
Mark A Row In My Mysql Database As To Be Delete
Is there a way in php that I can mark a row in my mysql database and then later so delete these rows that have been marked?

View Replies !
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.

View Replies !
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?

View Replies !
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.

View Replies !
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:

View Replies !
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.

View Replies !
MySQL Delete Only Deleting Content
I am working on a content editor for a client who wants tha ability to add new page. But he also has to be able to delete page. The pages are refered by their PID column which is set to auto increment.

However, when I delete a row, for some reason, it deletes the content in the row, but not the row itself. So, I have an empy row left which gets assigned a PID when I drop the PID column and reconstruct it with the new auto_increment numbers. What could be causing this? Or is there a way to renumber the auto_increments after a page has been deleted? My coding is a little rusty right now as I am out of practice. had to have a reference manual by my site at all times. PHP Code:

$sql     = "DELETE FROM $db_table WHERE PID = $id LIMIT 1";
$result = @mysql_query($sql, $db_connect) or die(mysql_error());

$drop     = "ALTER TABLE $db_table DROP COLUMN PID";
$result = @mysql_query($drop, $db_connect) or die(mysql_error());

$add    = "ALTER TABLE $db_table ADD PID INT NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST";
$result = @mysql_query($add, $db_connect) or die(mysql_error());

View Replies !
Time Limit To Delete From Mysql
on my site i allow users to upload .doc, .pdf and image files, over time these files will build up on the server and take up a bit of space, i was thinking of adding a "clean up" button in the admin section where files/users older than a certain time are deleted from mysql and the files (unlinked) can anyone advise me on the best way to acomplish this. i know i need to query the database then find all files uploaded (say after 28 days for example) is that on the right track or is there another way at all?

View Replies !
Delete Issues MySQL 4.0.25-standard
<?
include("../../includes/global.inc.php");
mysql_connect($glob['dbhost' ],$glob['dbusername' ],$glob['dbpassword' ]);
@mysql_select_db($glob['dbdatabase' ]) or die( "Unable to select database");

$query = "DELETE FROM testimonials WHERE id LIKE '$id'";

mysql_query($query);
echo "Record Deleted";
mysql_close();
?>
<META HTTP-EQUIV="refresh" content="0;URL=admintestimonials.php">

the issue is that it is not deleting the record. the $id is an echo from another page. I can see that it is echoing the id number just does not delete the record. any ideas?

View Replies !
Delete Mysql Query NOT USING SUB-SELECT.
I need a DELETE that represent the sql below:

SELECT L.pk FROM t1 L LEFT JOIN t2 F ON F.fk = L.pk WHERE F.fk IS NULL

NOT USING SUB-SELECT.

View Replies !
How Do I Delete From Table After Sorting? MySQL
I want to sort column X from largest to smallest, but I want to delete all the entries from all rows after the 25th place.

View Replies !
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?

View Replies !
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.

View Replies !
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:

View Replies !
How To Delete A MySQL Database Table Without System()
I want to delete a MySQL table without using functions of the OS, so
that my php script can run on any webserver. Can I use a command like

$sql = "DELETE FROM tablename";

or are there better ways to do the job?

View Replies !
Delete Record - When The Delete Link Is Clicked The Next Page Is Blank And Nothing Is Deleted.
This is my "delete.php" and this "todo/delete.php?id=64" an example of a link to it generated from the index.php page. When the delete link is clicked the next page is blank and nothing is deleted. What have I done wrong?

<?
include("dbinfo.inc.php");

mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");

$id="delete from todo where id='$id'";
mysql_query($id);

mysql_close();
?>

View Replies !
Give User Mysql Delete Privilege For One Query Via Is This Possible?
What i'm basically looking to do is give a user delete privileges for one query only. This is just so i can keep my database clean. Am i best just writing a DB logon script for that one query only and allowing that user to delete the records or is there a way PHP can grant delete for one query?

View Replies !
Automatic Delete From MySQL Database Table Expired Records?
I have a question . . .

how can i delete from MySQL database table automatic expired records ?
?

One think is to make a service that deleting the expired records . . .

Any other method ?



View Replies !
Script To Read/write/amend/delete On The Tables In A Mysql Db
Running on a unix box and looking for a good (free!) php script I can use to read/write/amend/delete on the tables in a mysql db. Been searching for a while but can seem to find one with a good web front end to use.

View Replies !
Simple Login Page To Delete And Edit Things In Mysql Database
How do I build a simple login page on my site? I need a way to login to my admin area in my webshop, so I can add, delete and edit things in mysql database. I don't need help with add, delete and change things, only the login thing.

The users should not even know that there is a admin login page. The users don't login to shop, they just shop so I can't use the user login page because there is no such page. Can someone please give me some guidelines for this?

View Replies !
Delete Query - Error In Your SQL Syntax; Check The Manual That Corresponds To Your MySQL Server
I have tried to make a delete query but it won't work it gives me a syntax error but I'm unsure where i have gone wrong.... this is what i have got at the moment:

Quote$Deletesoldhouses = "DELETE * FROM soldhouses WHERE SoldHouseID = '$HouseID'";
mysql_query($Deletesoldhouses) or die(mysql_error());

Can any one see what i did wrong?

Error:

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 '* FROM soldhouses WHERE SoldHouseID = '1'' at line 1

View Replies !
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.

View Replies !
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);

View Replies !
How To Delete
how to delete mysql row at php with checkbox?

View Replies !
Not Able To Delete
I've written a script to display all records in a database table and allow the user to select a record for deletion by entering it's ID number into a form at the bottom of the page.

When they click on the Submit button, it refreshes the page & shows the entire record that they selected and it asks if they're sure that they want to delete it.

There's 2 radio buttons that that allow them to select either "Yes" or "No". Everything is working fine up to that point. Where I run into problems is that no matter whether they choose yes or no, the record does not get deleted.

View Replies !
Delete Row
I am having a little problem with the following row to delete a row from my table. This script works fine on my home testing server but as soon as I put it onto my main web server it does not work and gives me an SQL syntax error. PHP Code:

mysql_select_db($database, $connect);
$sql = "DELETE FROM prices WHERE id=$id";
mysql_query($sql) or die(mysql_error());

View Replies !
Row Delete
what i am trying to do is delete all rows except for the last 20 rows, anyone know how this can be done?

basically i am keeping track of profile views so i know what members lasts seen who... my questin is how do i delete all but that last 2o for each $Member?

View Replies !
Delete
In one part of a review site i am making it allows top level users to make reviews witch includes uploading a picture and then changing the name to [name of review].[whatever], also it allows people to edit the review and change the picture, how exactly would i go about getting rid of the old picture so that i dont have to do hours of clean up.

View Replies !
Delete From Dir....
I have a field named 'path' in my db that has the exact same number(path) as its counterpart folder under cart/zips.

So my path in my db might be &#65533;', and in cart/zips you'd have the folder 23423423. There is a corresponding session with each 'path' row. Based on the session, I want to retrieve the path name and delete its counterpart folder name (and all it's sub-files it may contain).

The delete_all_from_dir function below is deleting the whole zips folder when I only want it to delete the path folder below it and its contents. Code:

View Replies !
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");

View Replies !
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.

View Replies !
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.

View Replies !

Copyright © 2005-08 www.BigResource.com, All rights reserved